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