把一个字符串分成N个字符串 每个字符串长度为m
Sample Input
1
2 5 // n m
klmbbileay
Sample Output
klmbb
ileay
1 # include <iostream> 2 # include <cstdio> 3 # include <cstring> 4 # include <algorithm> 5 # include <string> 6 # include <cmath> 7 # include <queue> 8 # include <list> 9 # define LL long long 10 using namespace std ; 11 12 char s[2000] ; 13 14 int main() 15 { 16 //freopen("in.txt","r",stdin) ; 17 int T ; 18 scanf("%d" , &T) ; 19 while(T--) 20 { 21 int n , m ; 22 scanf("%d %d" , &n ,&m) ; 23 int i , j ; 24 int cnt = 0 ; 25 scanf("%s" , s) ; 26 for (i = 0 ; i < n ; i++) 27 { 28 for (j = 0 ; j < m ; j++) 29 printf("%c" , s[cnt++]) ; 30 printf("\n") ; 31 } 32 33 34 } 35 36 return 0; 37 }
时间: 2024-10-01 04:39:52