int rows = 5;
int row = rows;
while (row >= 1) {
for (int space = 1; space <= rows - row; ++space) {
cout << " ";
}
for (int star = 1; star <= row; ++star) {
cout << "*";
}
cout << endl;
row--;
}
给你,只要
while
,哪怕只是一会儿,为了让你得到老师的特别关注。
#include <iostream>
int main() {
int place=1;
char output='*';
while (place<=25)
{
printf("%c", output);
if (!(place%5))
{
printf("\n");
output=' ';
}
if (!(place%6)) output='*';
place++;
}
}