2021-4-23【PTA】【跟奥巴马一切编程】

#include<bits/stdc++.h>
using namespace std;

int main(){
   
    int n;
    char c;
    cin>>n>>c;
    for(int i=1;i<=(n/2+n%2);i++){
   //确定行数 
        if(i==1||i==(n/2+n%2)){
   //判断是否为首行或尾行 
        	for(int j=0;j<n;j++)
        	{
   
        		cout<<c;//按首行尾行要求输出 
			}
			cout<<endl;//换行 
		}else{
   
			for(int j=1;j<=n;j++){
   
				if(j==1||j==n){
   //是否为每行的首尾 
					cout<<c;
				}else{
   
					cout<<" ";
				}
			}
			cout<<endl;//换行 
		}
    }
}
全部评论

相关推荐

没有offer的呆呆:薪资有的时候也能说明一些问题,太少了活不活得下去是一方面,感觉学习也有限
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务