欢度世界杯——打?门?

欢度世界杯——打?门?

Time Limit: 1000 ms Memory Limit: 65536 KiB
Submit Statistic
Problem Description
打门即射门。本次世界杯依然有许多精彩的打门瞬间,但是今天需要让大家打印一个从侧面看的球门。
打印球门需要用到的符号包括 ‘_’, ‘/’, ‘|’,需要大家来打印一个大小为n的球门哦,n代表门梁宽度和球门高度。
Input
输入数据有多组,到EOF结束。
每组数据输入一个整数n(1<=n<=10),代表球门的大小。
Output
对于每组数据,用指定的符号打印一个大小为n的球门,详情见示例输出。
Sample Input
1
2
3
Sample Output
_
/|
__
/ |
/ |


/ |
/ |
/ |
Hint

Source
【2017级–创新班《C语言》期末上机考试】玄黄

#include<stdio.h>

int main()
{
    int i,n;
    while(scanf("%d",&n)!=EOF)
    {
        for(i=0; i<n; i++)
            printf(" ");
        for(i=0; i<n; i++)
            printf("_");
        printf("\n");
        int p=n-1;
        while(n--)
        {
            for(i=0; i<n; i++)
            {
                printf(" ");
            }
            printf("/");
            for(i=0; i<p; i++)
                printf(" ");
            p++;
            printf("|\n");
        }
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_41938269/article/details/82082994