1027

作者: 峡迩 | 来源:发表于2017-07-30 21:19 被阅读0次
    // PATn.cpp : 定义控制台应用程序的入口点。
    //
    
    #include "stdafx.h"
    #include<iostream>
    #include<iomanip>
    #include<string>
    
    using namespace std;
    
    int main()
    {
        unsigned n;
        string c;
        cin >> n >> c;
    
        int ret = (n+1)/2;
        int max = 1;
        int sum = 0;
    
        while (ret>=1)
        {
            sum = sum + max;
            ret = ret - max;
            max = max + 2;
            if (max > ret)
                break;
        }
        max = max - 2;
    
    
    
        cout.flags(ios::right);
        for (int j = max; j > 0; j = j - 2)
        {
            cout.fill(' ');
            if(max==j)
                cout << setw((max - j) / 2) << "";
            else
                cout << setw((max - j)/2)<<" ";
            cout.fill(c[0]);
            cout << setw(j)<<c;
            cout << endl;
        }
    
        if (n>=7)
        {
            for (int j = 3; j <= max; j = j + 2)
            {
                cout.fill(' ');
                if (max == j)
                    cout << setw((max - j) / 2) << "";
                else
                    cout << setw((max - j) / 2) << " ";
                cout.fill(c[0]);
                cout << setw(j)<<c;
                cout << endl;
            }
        }
        if (n < 7)
            cout << n-1;
        else
            cout << n % (sum*2 - 1);
        
        return 0;
    }
    
    
    

    相关文章

      网友评论

          本文标题:1027

          本文链接:https://www.haomeiwen.com/subject/swbklxtx.html