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;
}
posted @ 2022-06-13 10:51  Ryomk  阅读(19)  评论(0编辑  收藏  举报