Print the case. There are 19 rows in total and there can only be one for loop (the question has been provided)
*
***
*****
*******
*********
***********
*************
***************
*****************
*******************
*****************
***************
*************
***********
*********
*******
*****
***
*
For (I = 0; I <19; I ++)
{
}
I searched for some answers online, as shown below:
1.
# Include <iostream>
# Include <iomanip>
# Include <string>
Using namespace STD;
Int main ()
{
Int A [2] = {-1, 1 };
String STR = "*******************";
Int I = 0, j = 9, T = 1;
For (I = 0; I <19; ++ I)
{
J + = A [I <10];
If (I! = 0) t = T + A [I <10] * 2;
Cout <SETW (j) <right <Str. substr (0, T) <Endl;
}
Return 0;
}
2.
# Include <stdio. h>
# Include <string. h>
Int main ()
{
Char * tempstr = "*******************";
Char * blank = ""; int I = 0;
Char * datastr [20];
Char blankstr [10]; for (I = 0; I <19; I ++)
{
Memset (datastr, 0, 20 );
Memset (blankstr,); if (I <10)
{
Memcpy (blankstr, blank, 9-I );
Memcpy (datastr, tempstr, (I + 1) * 2-1 );
}
Else
{
Memcpy (blankstr, blank, I-9 );
Memcpy (datastr, tempstr, (19-i) * 2-1 );
}
Printf ("% s", blankstr );
Printf ("% s \ n", datastr );
}
Return 0;
}