-
Notifications
You must be signed in to change notification settings - Fork 0
/
00488 Triangle Wave.cpp
executable file
·53 lines (40 loc) · 1.03 KB
/
00488 Triangle Wave.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <iostream>
using namespace std;
int main()
{
int amplitude, frequency, test, i, k, counter, temp = 0, flag = 0;
cin >> test;
for(int p = 1; p <= test; p++)
{
cin >> amplitude >> frequency;
if(p > 1 && p <= test) cout << "\n";
for(i = 1, flag = 1; i <= frequency; i++)
{
for(k = 1; k < amplitude; k++)
{
counter = k;
while(counter--)
{
cout << k;
}
cout << "\n";
}
for(k = amplitude; k > 0; k--)
{
counter = k;
while(counter--)
{
cout << k;
}
if (k == 1 && i == frequency == 1)cout << "";
else cout << "\n";
}
cout << "\n";
flag = 1;
}
if(i == frequency - 1) flag = 0;
if (flag == 0) cout << "\n\n";
flag = 1;
}
return 0;
}