Skip to content

Instantly share code, notes, and snippets.

@Abreto
Created February 3, 2013 08:37
Show Gist options
  • Save Abreto/4700958 to your computer and use it in GitHub Desktop.
Save Abreto/4700958 to your computer and use it in GitHub Desktop.
UVa 488 - Triangle Wave.
/* UVa 488 - Triangle Wave. */
#include <stdio.h>
int main()
{
int i = 0, j = 0, k = 0;
int T = 0;
int A = 0, F = 0;
int fcount = 0;
int h = 0;
scanf("%d", &T);
while(T--)
{
scanf("%d\n%d", &A, &F);
for(i = 0;i < F;i++)
{
if( fcount > 0 )
printf("\n");
for(j = 0;j < 2*A-1;j++)
{
h = ((j+1)>A)?(A-(((j)%A)+1)):(j+1);
for(k = 0;k < h;k++)
printf("%d", h);
printf("\n");
}
fcount ++;
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment