码迷,mamicode.com
首页 > 其他好文 > 详细

1036 跟奥巴马一起编程

时间:2020-02-19 13:26:21      阅读:52      评论:0      收藏:0      [点我收藏+]

标签:using   输出   names   ace   return   ++   stream   round   style   

水题。

#include<iostream>
#include<cmath>
using namespace std;

int main() {
    int n,m;
    char c;
    cin>>n>>c;
    m = round(n/2.0)-2;//行数
    for(int i =0; i< n; ++i)//输出第一行
        cout<<c;
    printf("\n");
    for(int i = 0; i < m; ++i) {//输出第二行到倒数第二行
        cout<<c;
        for(int j = 0; j < n-2; ++j)
            printf(" ");
        cout<<c;
        printf("\n");
    }
    for(int i =0; i< n; ++i)//输出最后一行
        cout<<c;
    return 0;
}

技术图片

 

1036 跟奥巴马一起编程

标签:using   输出   names   ace   return   ++   stream   round   style   

原文地址:https://www.cnblogs.com/keep23456/p/12330654.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!