@Output of graph * in C language

## 1. Simple * figure (square)

**** * * * * **** * * * * **** * * * * //Now we're going to start typing #include <stdio.h> { int i,j; for (i=0;i<3;i++) //The first for statement is to control several lines and the second is to control several columns; { for(j=0;j<4;j++) printf("*"); //Or printf ("*") with a space difference printf("\n"); } }

Add some difficulty and make a mistake

**** * * * * **** * * * * **** * * * * //If there is a misplacement, you need to input the space bar, and add a circular statement based on the above int i,j,k; for (i=0;i<3;i++) { for(k=0;k<3-i;k++) //It can be n-i. pay attention to the fact that the dislocation of each line is 1 printf(" "); //The two for statements are dropped side by side, that is, after the space is filled with * and then the next line break for(j=0;j<4;j++) printf("*"); //Or printf ("*"); printf("\n"); }

## 2. Moderate * figure (diamond)

* * * * * * //The output number of each line is different, so we need to limit it. In fact, like the above program, we just need to change it int i,j,k; for (i=0;i<3;i++) { for(k=0;k<3-i;k++) printf(" "); for(j=0;j<= **i** ;j++) //Just replace 4 with i, because the output of each line is exactly incremental; printf("*"); printf("\n"); }

Well, add a little more difficulty and have a symmetrical one;

* * * * * * * * * //Looking at the picture, the code is also symmetrical; int i,j,k; for (i=0;i<3;i++) { for(k=0;k<3-i;k++) printf(" "); for(j=0;j<= **i** ;j++) printf("*"); printf("\n"); } for (i=0;i<2;i++) //There are two lines left { for(k=0;k<=i+1;k++) //Space is also from less to more. Note that here is i+1(1, 2 spaces per line) printf(" "); Because at the beginning, we were 3-i(3, 2, 1 spaces per line) for(j=0;j<2-i ;j++) //Note that drops are reduced in turn printf("*"); printf("\n"); }

When you don't know the number of cycles, think of yourself as a robot, and substitute the numbers one by one

## 3. Complex figure (cardioid)

To borrow the figure on the Internet, all figures are composed of functions, and so is the heart shape; the heart shape function is (x2+y2-1) 3-x2y3=0, and the internal function of the heart shape is less than zero drop!

*** *** ****** ****** *********** ********* ***** *** //The actual operation is the first picture filled, hee hee; float x,y,a; for (y=1.5f;y>-1.5f;y-=0.1)//According to the range of the image, pay attention to the picture; (several lines) { for (x=-1/5f;x<1.5f;x+=0.05f)//(several columns) {a=x*x+y*y-1; putchar(a*a*a-x*x*y*y*y <=0.0f ? '*' : ' ');} printf("\n"); }

These graphs are all related to for statements, and are also the output of spaces and *, so please observe more and come on!!!