1036

作者: 峡迩 | 来源:发表于2017-09-02 22:28 被阅读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;
    }
    
    
    

    相关文章

      网友评论

          本文标题:1036

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