National Day Our laboratory has set up homework, one of which is to use the Process Control statements to print the shape
*
***
*****
*******
*****
***
*
The code is as follows
#include <stdio.h>
int main ()
{
int a,b,c;
for (a=0;a<=3;a++)
{for (b=0;b<=3-a;b++)
printf ("");
for (c=0;c<=2*a;c++)
printf ("*");
printf ("\ n");
}
for (a=0;a<=3;a++)
{
for (b=0;b<=a+1;b++)
printf ("");
for (c=0;c<=4-2*a;c++)
printf ("*");
printf ("\ n");
}
After finishing this assignment, I had the whim to make this kind of graphic, so that I could make a love pattern with a similar process control Statement. (programmer's Romance)
So I imagined a picture like This.
* *
*** ***
*********
*******
*****
***
*
PS1 (here because the typography is not very GOOD)
PS2 (because It is a beginner, so you can only do this simple pattern)
In the first half I couldn't figure out what algorithm to use, so I used only the most rudimentary printf to print (hopefully a great God can teach me how to do it)
In the second half I refer to our work and use the Process Control statements to complete
The final code is like This.
#include <stdio.h>
int main ()
{
int a,b,c;
printf ("* * \ n");
printf ("* * * * \ n");
For (a=0;a<=8;a++)
{
For (b=1;b<=a;b++)
printf ("");
For (c=0;c<=8-2*a;c++)
printf ("*");
printf ("\ n");
}
Return 0;
}
I think that in addition to printing with printf only, This is the most humble way of painting love, the search on the internet is using coordinates and so on, which I have not learned at Present.
Although the code is very primitive, but still can not help to share with you, if there is a more fool-like and more beautiful or efficient way, I hope to have the great god Guidance.
To love with C Language.