Home > Back-end >  Brothers, to solve
Brothers, to solve

Time:02-22

#include
Int main ()
{
Int I, j, k;
for(i=1; I<=4; I++)
{
for(j=0; J{
Printf (" ");
}
for(k=0; k<5 - I; K++)
//for (k=4; k<5 - I; K -) why will top the for (k=0; k<5 - I; K++) with my comment is not ah, solving?
{
Printf (" * ");
}
Printf (" \ n ");
}
return 0;
}

CodePudding user response:

Reference:
 # include & lt; Stdio. H> 
Int main ()
{
Int I, j, k;
for(i=1; I<=4; I++)
{
for(j=0; J{
Printf (" ");
}
//for (k=0; k<5 - I; K++)//this is k=0, perform k<5 - I printf (" * "), k++;
//I=1, k=0 & lt; 5 - I==4, 5-1 condition is met, execute the printf (" * "), k++;
//I=2, k=0 & lt; 5 - I=5-2=3, the condition is met, execute the printf (" * "), k++;
//I=3,,,,,,,,,

For (k=5 - I; K> 0; K -)//should it in reverse, k=5 - I, perform 5 - i> Zero printf (" * "), k -;

//for (k=4; k<5 - I; K -)//why the above for (k=0; k<5 - I; K++) with my comment is not ah, solving?
{//when I=1, the condition is k=4, k=4 & lt; 5 - I==4, 5-1 conditions are not met, just jump out of the loop the
Printf (" * ");//when I=2 k=4 & lt; 5 - I=5-2, still does not meet the conditions, jump out of the loop
}//I=3,,,,,,,,,
Printf (" \ n ");
}
system("pause");
return 0;
}