I just coded number pyramid:
Code:
#include <stdio.h>
int main (int argc, const char * argv[]) {
int i, j, k, l;
int number = 0;
l = 1;
for (i = 0; i < 10; i++) {
for (j = 10; j > i; j--)
printf(" ");
for (k = 0; k < l; k++)
printf("%d", number);
printf("\n");
l += 2;
number += 1;
}
return 0;
}
Code works great and the outputs number pyramid(Looks like the forum doesn't show it right, but I'm sure you know what pyramid is ):
0
1 1 1
2 2 2 2 2
3 3 3 3 3 3 3
4 4 4 4 4 4 4 4 4
5 5 5 5 5 5 5 5 5 5 5
6 6 6 6 6 6 6 6 6 6 6 6 6
7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9
But I want the output be like this (Looks like the forum doesn't show it right, but I'm sure you know what pyramid is ):
1
2 3 2
3 4 5 4 3
4 5 6 7 6 5 4
5 6 7 8 9 8 7 6 5
6 7 8 9 0 1 0 9 8 7 6
7 8 9 0 1 2 3 2 1 0 9 8 7
8 9 0 1 2 3 4 5 4 3 2 1 0 9 8
9 0 1 2 3 4 5 6 7 6 5 4 3 2 1 0 9
0 1 2 3 4 5 6 7 8 9 8 7 6 5 4 3 2 1 0
I just cant figure it out how to do it. Any ideas?