注释如下:

#include <stdio.h>

int main() {
// 定义变量 int i, space, rows, k=0;
// 输入行数 printf("Enter number of rows: ");
scanf("%d",&rows);
// 外循环控制行数 for(i=1; i<=rows; ++i, k=0)
{
// 内循环控制空格数 for(space=1; space<=rows-i; ++space)
{
printf(" ");
}
// 内循环控制星号数 while(k != 2i-1)
{
printf("
");
++k;
}
printf("\n");
}
return 0; }

输出结果:

Enter number of rows: 5 * * * * * * * * *



#include stdioh int main int i space rows k=0; printfEnter number of rows ; scanfd&rows; fori=1; i=rows; ++i k=0 forspace=1; space=rows-i; ++space

原文地址: https://www.cveoy.top/t/topic/bwv3 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录