话不多说,直接上代码,如题所示! #include <stdio.h> int main(){ int a ,b ,c ,d ; printf("请输入一个正整数:"); scanf("%d",&d ); for (a=1; a<=d; a++) { for (b=1; b<=d-a; b++) { printf(" "); } for (c=1; c<=2*a-1; c++) { printf("*"); } printf("\n"); } for (a=1; a<=d; a++) { for (b=1; b<=a; b++) { printf(" "); } for (c=1; c<=(2*d-1)-2*a; c++) { printf("*"); } printf("\n"); } return 0; }
|