"Algorithm Notes" Section 3.3 - Getting Started simulate -> graphic output
A no difficulty, pay attention to the beginning of a formula directly counted 5 actually denote by h, there is 2i plus to minus 2, because i starting at 1.
#include<stdio.h> int main() { int h; while(scanf("%d",&h)!=EOF) { for(int i=1;i<=h;i++) { int len=2*h-2*i; while(len--) printf(" "); for(int j=1;j<=h+2*i-2;j++) printf("*"); printf("\n"); } } return 0; }