You won't learn anything until you start to mess with these things yourself. All it takes is a bit of effort to do your homework. It took me 5 minutes to do this, you can probably write better code than this too: [code] #include
int main() { int n=0, i,j;
for (i=1; i<5; i++) { for (j=i; j>0; j--) { printf("%u ", n); n++; } if (n == 6) puts("and"); else putchar(' '); }
n=0; for (i=0; i<5; i++) { n += i; for (j=1; j<=i; j++) { printf("%u ", n-j); } putchar(' '); }
Comments
[code]
#include
int main()
{
puts ("0
"
"1 2
"
"3 4 5 and
"
"6 7 8 9
"
"
"
"0
"
"2 1
"
"5 4 3
"
"9 8 7 6"
);
return 0;
}
[/code]
[code]
#include
int main()
{
int n=0, i,j;
for (i=1; i<5; i++)
{
for (j=i; j>0; j--)
{
printf("%u ", n);
n++;
}
if (n == 6)
puts("and");
else
putchar('
');
}
n=0;
for (i=0; i<5; i++)
{
n += i;
for (j=1; j<=i; j++)
{
printf("%u ", n-j);
}
putchar('
');
}
return 0;
}
[/code]