c语言之菱形输出

时间:2026-02-14 14:59:43

1、 写入头文件

#include"stdio.h"

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

3、 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");   } 

4、   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(); }下面是运行结果

c语言之菱形输出

c语言之菱形输出

© 2026 海能知识库
信息来自网络 所有数据仅供参考
有疑问请联系站长 site.kefu@gmail.com