#include<stdio.h> void solve(int h){ int N=h+2*(h-1); int i=N-h; int j=0; int t=h; int k; for(;j<h;++j){ for(k=0;k<i;++k){ printf(" "); } i-=2; for(k=0;k<t;++k) printf("*"); t+=2; printf("\n"); } } int main(int argc, char *argv[]) { // freopen("1065.in", "r", stdin); int h; while(~scanf("%d",&h)){ solve(h); } return 0; } /************************************************************** Problem: 1065 User: kirchhoff Language: C Result: Accepted Time:240 ms Memory:912 kb ****************************************************************/
原文地址:http://blog.csdn.net/wdkirchhoff/article/details/41927319