程序代码:
#include<stdio.h> void main() { int n,t,i,k,m; while (scanf("%d",&n)!=EOF) { t=n/2; for (i=0;i<=t;i++) { for (k=i;k<t;k++) printf(" "); for (m=n;m>=n-i*2;m--) printf("*"); printf("\n"); } for (i=1;i<=t;i++) { for (k=t;k>=t-i+1;k--) printf(" "); for (m=i*2;m<n;m++) printf("*"); printf("\n"); } } }仅供参考