c语言之菱形输出

作者:哈哈小脸 | 创建时间: 2023-07-12
利用输出函数怎么输出菱形呢?,下面介绍具体c代码...
c语言之菱形输出

操作方法

写入头文件 #include"stdio.h"

main(){  int i,j,row;    /*变量的定义*/

for(row=1;row<=4;row++)   /*前四排星号*/  { for(i=1;i<=4-row;i++) printf(" ");    for(j=1;j<=2*row-1;j++) printf("*");    printf("\n");   }

for(row=1;row<=3;row++)   /*后三排星号*/  { for(i=1;i<=row;i++) printf(" ");    for(j=1;j<=2*(4-row)-1;j++) printf("*");    printf("\n");   } getch(); }下面是运行结果

温馨提示

注意循环的控制
点击展开全文

更多推荐