-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path488 - Triangle Wave.c
58 lines (52 loc) · 1.18 KB
/
488 - Triangle Wave.c
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
53
54
55
56
57
58
#include<stdio.h>
int main()
{
int n,i,j,k,l;
while(scanf("%d",&n)==1)
{
int a[n];
int b[n];
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
scanf("%d",&b[i]);
}
for(i=0;i<n;i++)
{
for(j=0;j<b[i];j++)
{
int c = (a[i]*2)-1;
int p=1;
for(k=0;k<c;k++)
{
if(k+1>a[i])
{
for(l=0;l<=k-p-1;l++)
{
printf("%d",k-p);
}
printf("\n");
p=p+2;
}
else
{
for(l=0;l<=k;l++)
{
printf("%d",k+1);
}
printf("\n");
}
}
if(j<b[i]-1)
{
printf("\n");
}
}
if(i<n-1)
{
printf("\n");
}
}
}
return 0;
}