Sunday, August 2, 2009

Write c code for folliwing on the center of screen?

1


1 2 1


1 2 3 2 1


1 2 3 4 3 2 1

Write c code for folliwing on the center of screen?
There are many ways to do this. I don't want to do your homework for you, but this (untested) code should get you started.





int min, max,


min = 1;


max = 4;





for (int i = min; i %26lt;= max; i++) {


for (int j = min; j %26lt;= i; j++) {


cout %26lt;%26lt; j;


}


for (int k = i; k %26gt;= min; k--) {


cout %26lt;%26lt; k;


}


cout %26lt;%26lt; "\n";


}


No comments:

Post a Comment