PTA GPLT L1-039 古风排版

#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	getchar();
	string s;
	getline(cin,s);
	int l=s.size();
	int d=l%n;//补几个空格
	if(d!=0) d=n-d;//取模的时候,永远记得考虑0
	while(d--) s+=" ";
	l=s.size();
	for(int i=0;i<n;++i){
		for(int j=l-1;j>=0;--j){
			if(j%n==i)cout<<s[j];
		}
		cout<<"\n";
	}
} 

猜你喜欢

转载自blog.csdn.net/weixin_42104573/article/details/88357708