//L1-039 古风排版 (20 分)
//https://pintia.cn/problem-sets/994805046380707840/problems/994805091888906240
#include<stdio.h>
#include<string.h>
int main(void){
int N; char str[5000] = {0}; int col, len, x;
x = 0;
scanf("%d", &N);
//每列n个字符,就是N行 strlen列
//创建一个这样的字符数组
getchar();
gets(str);
len = strlen(str);
//计算出列数
col = len/N;
if(len%N!=0){
col++;
}
char anc[N][col];
//从最后一列开始往前,
//先变得是行数
int i, j;
for(i=col-1; i>=0; i--)
for(j=0; j<N; j++){
{
if(x<len){
anc[j][i] = str[x];
x++;
}
else{
anc[j][i] = ' ';
}
}
}
//打印
for(i=0; i<N; i++){
for(j=0; j<col; j++){
printf("%c", anc[i][j]);
}
printf("\n");
}
}
注意,一列没填满的时候要加空格