HZNUOJ 2689 阅兵

Input

第一行给出一个正整数T,代表接下来会有T组输入。

紧接着给出T行,每行有一个正整数n(2≤n≤100)

Output

请观察样例,画出大小为n的飞机,每两组样例之间有一个空行,行末没有多余空格,也没有多余空行。

 解题思路:水题,有耐心就行,无聊的时候可以画个飞机玩一玩xD

ac代码:

#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    while (t--) {
        int n;
        cin >> n;
        int m = n;
        int a = 4 * n - 1;
        int b = n - 2;
        int u = 0;
        int o = 2 * n - 1;
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= o; j++) {
                cout << ' ';
            }
            if (i == 1) cout << '*' << endl;
            else {
                cout << '*';
                for (int y = 1; y <= u; y++) cout << ' ';
                cout << '*' << endl;
            }
            if (i != n) u = 2 * i - 1;
            o--;
        }
        for (int i = 1; i <= n + 1; i++) {
            cout << '*';
        }
        for (int i = 1; i <= u; i++) cout << ' ';
        for (int i = 1; i <= n + 1; i++) {
            cout << '*';
        }
        cout << endl;
        for (int k=1;k<=b;k++){
        cout << '*';
        for (int i = 1; i <= u + 2 * n; i++) cout << ' ';
        cout << '*' << endl;
    }
        for (int i=1;i<=n+1;i++)
        {
            cout << '*';
        }
        for (int i=1;i<=u;i++) cout << ' ';
        for (int i=1;i<=n+1;i++)
        {
            cout << '*';
        }cout << endl;
        for (int i=1;i<=n;i++)
        {
            if(i!=n)
            {
                for (int j=1;j<=n;j++) cout << ' ';
                cout << '*';
                for (int j=1;j<=u;j++) cout << ' ';
                cout << '*' << endl;
            } else
            {
                for (int j=1;j<=n;j++) cout << ' ';
                for (int j=1;j<=u+2;j++) cout << '*';
            }
        }
        cout << endl << endl;
    }
    return 0;
}

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值