网站首页 美食营养 游戏数码 手工爱好 生活家居 健康养生 运动户外 职场理财 情感交际 母婴教育 时尚美容

c语言之菱形输出

时间:2024-10-27 16:12:46

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语言之菱形输出
© 2025 小知经验
信息来自网络 所有数据仅供参考
有疑问请联系站长 site.kefu@gmail.com