C language exercises - graphics output to the triangle

Title :
No Input
Output Format:
following format output from the " " pattern composed of inverted triangle.
Here Insert Picture Description
Method a: direct output;
#include <stdio.h>
int main (void) {
the printf ( "
* * * \ n-");
the printf ( "* * * \ n-");
the printf ( "* * \ n-") ;
printf ( "* \ the n-");

return 0;

}
This method does not have a universal
two: two heavy cycle
points:
① Number outer circulation pipe line, the inner loop responsible for the content of each row (row number i from zero)
② initial number of spaces in each row is 0, 1, 3, thus the inside with a printing space for loop
(line number is just the number of spaces)
③ each row "*" 3,2,1,0 atoms; (I-number is. 3)
④ at the end of each row is " "no space, and containing newline" \ n-"
#include <stdio.h>
int main ()
{
for (int I = 0; I <. 4; I ++) // number of rows
{
for (int J = 0; J <I; J ++)
the printf ( ""); // number of spaces
for (int. 3-I = K; K> 0; - K-)
the printf ( "
"); // '*' number
printf ( "* \ n ");
}

return 0;

}

Published an original article · won praise 0 · Views 11

Guess you like

Origin blog.csdn.net/fengshuo16/article/details/104682466