其他分享
首页 > 其他分享> > PAT甲级刷题日记(三)

PAT甲级刷题日记(三)

作者:互联网

1031 Hello World for U

Mon Jun 13 10:45
Link
20分

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
using namespace std;
string s;
int main(){
	#ifdef ONLINE_JUDGE
	#else
	freopen("/Users/preccrep/Developer/RandomCoding/2.txt","r",stdin);
	#endif
	cin>>s;
	int n=s.size(),n1,n2;
	n1=(n+2)/3;
	n1--;
	n2=n-n1-n1;
	for(int i=0;i<n1;++i){
		cout<<s[i];
		for(int j=0;j<n2-2;++j)
			cout<<" ";
		cout<<s[n-1-i]<<endl;
	}
	cout<<s.substr(n1,n2)<<endl;
	return 0;
}

标签:PAT,int,Jun,甲级,n1,n2,include,刷题
来源: https://www.cnblogs.com/preccrep/p/16370070.html