29. Nine rows and nine columns 02

/*
The loop variable of the inner loop cannot be the loop variable of the outer loop
*/
#include "stdio.h"
void main()
{
int r,c;

for(r=1;r<=9;r++)//Controlled is the number of lines
{
for(c=1;c<=r;c++)//the number of columns in each line
{
printf("*");
//printf("%d*%d=%d\t",r ,c,r*c);
}
printf("\n");
}

printf("\n\n");//Use to separate two triangles

for(r=1;r<=9;r++) //Control is the number of rows
{
for(c=1;c<=r;c++)//The number of columns in each row
{
if(r==9||c==1||c==r)
printf( "*");
else
printf(" ");
}
printf("\n");
}

printf("\n\n");//Use to separate two triangles

for(r=9;r>= 1;r--)//The number of rows is controlled
{
for(c=1;c<=r;c++)//The number of columns in each row
{
printf("*");
}
printf("\n");
}

printf("\n\n");//Use to separate two triangles

for(r=9;r>=1;r-- )//The number of rows is controlled
{
for(c=1;c<=r;c++)//The number of columns in each row
{
if(r==9||c==1||c==r)
printf ("*");
else
printf(" ");
}
printf("\n");
}

printf("\n\n");//Use to separate two triangles

for(r=1;r< =9;r++)//The number of lines is controlled
{
for(c=1;c<=9-r;c++)
{
printf(" ");
}
for(c=1;c<=r;c++)/ /Number of columns per line
{
printf("*");
}
printf("\n");
}

printf("\n\n");//Use to separate two triangles

for(r=9;r >=1;r--)//The number of lines is controlled
{
for(c=1;c<=9-r;c++)
{
printf(" ");
}
for(c=1;c<=r;c++)//number of columns per line
{
printf("*");
}
printf("\n");
}

printf("\n ");//Separate two triangles
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325808962&siteId=291194637