题目大意:给出一个字符串以及n,m,要求将其按照n行m列进行输出。
解题思路:直接就暴力输出,按照先行后列进行输出即可。其实更快的写法是边接收边输出。
题目来源:http://acm.hdu.edu.cn/showproblem.php?pid=4813
code:
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int MAXN = 1000+10;
int l,m,n;
char str[MAXN];
int main(){
//freopen("input.txt","r",stdin);
scanf("%d",&l);
while(l--){
memset(str,0,sizeof(str));
scanf("%d%d",&n,&m);
scanf("%s",str);
for(int i=0;i<n;++i){
int tmp=i*m;
for(int j=0;j<m;++j){
printf("%c",str[tmp+j]);
}
printf("\n");
}
}
return 0;
}