1036

2017-09-02  本文已影响0人  峡迩
// 为什么无法通过?
//

#include "stdafx.h"
#include<iostream>
#include<cmath>
#include<string>

using namespace std;

int main()
{
    unsigned n;
    char p_char;
    cin >> n >> p_char;

    unsigned row = round(n / 2.0);      //  n/2,此为整除!
    cout << row << endl;
    unsigned col = n;

    for (unsigned i = 0; i < row;++i)
    {
        string tmp;
        if (0 == i || (row - 1) == i)
        {
            tmp = string(n, p_char);
            cout << tmp;
            if (0 == i)
            {
                cout << endl;
            }
        }
        else
        {
            tmp = string(1, p_char) + string((n - 2),' ') + string(1, p_char);
            cout << tmp << endl;
        }
    }


    system("pause");
    return 0;
}


上一篇下一篇

猜你喜欢

热点阅读