C语言打印倒三角形

C语言打印倒三角形

输入正整数n<=20,输出一个n层的倒三角形。

#include 
#include 
#include 
#include 

/*
int main()
{
    int num;
    char triangle[40];//可删去

    while(scanf("%d",&num)==1){
        for(int count1=0;count1<40;count1++){
            triangle[count1]='#';
        }
        for(int count1=0;count1if(count1-1>=0){
                count2=count1-1;
                triangle[count2]=' ';
                triangle[2*num-2-count2]=' ';
            }
            for(int count2=0;count2<2*num-1;count2++){
                printf("%c",triangle[count2]);
            }
            printf("\n");
        }
    }
}
*/

int main(){
    int num;
    while(scanf("%d",&num)!=EOF){
        for(int count1=0;count1for(int count2=0;count2printf(" ");
            }
            for(int count2=count1;count2<=2*num-2-count1;count2++){
                printf("#");
            }
            printf("\n");
        }
    }
}

你可能感兴趣的:(算法竞赛入门经典-第2版)