PAT图形输出---1036 跟奥巴马一起编程 (15分)

1036 跟奥巴马一起编程 (15分)
注意一下空格就行了

#include<iostream>
#include<algorithm>

using namespace std;

int main(){
	int n,m;string s;
	cin>>n>>s;
	if(n%2){
		m=n/2+1;
	}else{
		m=n/2;
	}
	for(int i=1;i<=m;i++){
		for(int j=1;j<=n;j++){
			if(i==1||i==m){
				cout<<s;
			}
			else{
				if(j==1||j==n){
					cout<<s;
				}else{
					cout<<" ";
				}
			}
		}
		cout<<"
";
	}
	return 0;
}

原文地址:https://www.cnblogs.com/bingers/p/13064437.html