pat甲级1031

pat1031

#include<iostream>
#include<cmath>
using namespace std;
int main(){
	string s;
	cin>>s;
	int n1,n2;
	n2=ceil(s.length()+2)/3;
	while(n2<3||(s.length()-n2)%2!=0||(s.length()-n2+2)/2>n2)
		n2++;
	n1=(s.length()-n2)/2;
	for(int i=0;i<n1;i++){
		cout<<s[i];
		for(int j=0;j<n2-2;j++)
			cout<<" ";
		cout<<s[s.length()-i-1]<<endl;
	}
	for(int i=n1;i<s.length()-n1;i++)
		cout<<s[i];
	cout<<endl;
	return 0;
} 
上一篇:pat-1031


下一篇:1031 Hello World for U (20分)