Skip to content

Instantly share code, notes, and snippets.

@KhaledElshamy
Created July 11, 2016 21:35
Show Gist options
  • Select an option

  • Save KhaledElshamy/e7ba0bfbad2ae6e537b0b1c293c0389b to your computer and use it in GitHub Desktop.

Select an option

Save KhaledElshamy/e7ba0bfbad2ae6e537b0b1c293c0389b to your computer and use it in GitHub Desktop.
URI ONLINE JUDGE 1478
#include <stdio.h>
int main(void) {
// URI ONLINE JUDGE 1478
int x, n, i, j,k, y,a;
for (;;)
{
scanf("%d", &n);
if (n == 0)break;
for (i = 1;i <= n;i++)
{
x = i;
k = i;
for (j = 1;j <= n;j++)
{
y = j;
if (x > y)
{
printf("%3d ", k);
k--;
}
else if (i == y)
{
a = 1;
printf("%3d ", a);
}
else if (x < y)
{
a++;
printf("%3d ", a);
}
}
printf("\n");
}
printf("\n");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment