B1036. 跟奥巴马一起编程

时间:2020-02-19 19:54:11   收藏:0   阅读:53

技术分享图片

基本思路

#include <bits/stdc++.h>

using namespace std;

int main(int argc, char* argv[]) {
    int n, j;
    char ch;
    cin >> n >> ch;    
    for(int row = 0, col = n/2 - 1; row <= col; row++){
        if(row == 0 || row == col){
            j = n;
            while(j-- > 0){
                cout << ch; 
            }
            cout << endl;
        }else{
            cout << ch;
            j = n;
            while(j-- > 2){
                cout << " ";
            }
            cout << ch << endl;
        }
    }    
    return 0;
}

原文:https://www.cnblogs.com/YC-L/p/12332522.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!