#include #include using namespace std; int main() { int n,len; string s; cin>>n>>s; len=s.size(); int k=(len+n-1)/n;//k为列数,向上取整 for(int i=0;i<n;++i) for(int j=0;j<k;++j) { int idx=j*n+(n-i-1);//idx为s中对应字符的下标 if(idx<len) cout<<s[idx];//如果下标在字符串内,输出该字符 else cout<<' ';//否则输出空格 } return 0; }


原文地址: https://www.cveoy.top/t/topic/oQTj 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录