Coder

舒心、快乐,比什么都重要

1036 跟奥巴马一起编程 (15 分)

#include <iostream>
using namespace std;
int main(){
    int n, m;
    char ch;
    cin >> n >> ch;  
    if (n % 2 == 0)  // 行数的奇偶变化
        m = n / 2;
    else
        m = n / 2 + 1;
    for (int i = 0; i < m; i++){
        for (int j = 0; j < n; j++){
            if (i == 0 || j == 0 || i == m - 1 || j == n - 1)  //找出规律便可
                cout << ch;
            else
                cout << ' ';
        }
        cout << endl;
    }
    return 0;
}

 

posted @ 2019-04-17 19:51  H123K  阅读(108)  评论(0编辑  收藏  举报