To output a case on the screen:
*
***
*****
*******
*********
***********
*************
***********
*********
*******
*****
***
*
EG1:
voidfun1 () {printf ("* \ n"); }voidfun2 () {printf ("* * \ n"); }voidFun3 () {printf ("* * * \"); }voidFun4 () {printf ("******* \ n"); }voidfun5 () {printf ("********* \ n"); }voidfun6 () {printf ("*********** \ n"); }voidfun7 () {printf ("*************\n"); }intMain () {fun1 (); Fun2 (); Fun3 (); Fun4 (); Fun5 (); Fun6 (); Fun7 (); Fun6 (); Fun5 (); Fun4 (); Fun3 (); Fun2 (); Fun1 (); return 0; } This way, I can think of the simplest and most of the action, is the full output ~ ~ ~
EG2:
intMain () {inti,j; for(i=1;i<8; i++) { for(j=0;j<8-I.; j + +) printf (" "); for(j=0;j<2*i-1 ; j + +) printf ("*"); printf ("\ n"); } for(i=8;i>0; i--) { for(j=7-i;j>=0; j--) printf (" "); for(j=2*i-2; j>=0; j--) printf ("*"); printf ("\ n"); } return 0;}
This method looks comfortable, determines the number of rows, the main algorithm (or point of thinking) in the relationship between ' and ' * ' and the number of rows in the color of the relationship between the number of spaces and lines, the underscore is the relationship between * and the number of rows the second block of code is to write the relationship of the first block in reverse.
* Tower, Diamond