Description
Group reversing a string means reversing a string by groups. For example consider a string:
對字串進行分組反轉意味著按組反轉字串。例如,考慮一個字串:
“TOBENUMBERONEWEMEETAGAINANDAGAINUNDERBLUEICPCSKY”
"TOBENUMBERONEWEMEETAGAINANDAGAINUNDERBLUEICPCSKY"
This string has length 48. We have divided into 8 groups of equal length and so the length of each group is 6. Now we can reverse each of these eight groups to get a new string:
此字串長度為48,假設我們把該字串分成8個長度為6的群組,對每個群組內的字串分別做反轉,會得到另一個新字串:
“UNEBOTNOREBMEEMEWENIAGATAGADNAEDNUNIIEULBRYKSCPC”
"UNEBOTNOREBMEEMEWENIAGATAGADNAEDNUNIIEULBRYKSCPC"
Given the string and number of groups in it, your program will have to group reverse it.
給定群組數目及字串,請你分組反轉字串。
Input
The input file contains at most 101 lines of inputs. Each line contains at integer G (G < 10) which denotes the number of groups followed by a string whose length is a multiple of G. The length of the string is not greater than 100. The string contains only alpha numerals. Input is terminated by a line containing a single zero.
每行包含一個整數G (G < 10),表示群組數。接著是一個字符串,其長度為G的倍數。字符串長度不大於100。字符串僅包含英文字母。當G為0代表輸入結束。
Output
For each line of input produce one line of output which contains the group reversed string.
對於每一行輸入,輸出此字符串的Group reversing。
Sample Input 1
3 ABCEHSHSH
5 FAOETASINAHGRIONATWONOQAONARIO
0
Sample Output 1
CBASHEHSH
ATEOAFGHANISTANOIRAQONOWOIRANO
Hint
G represents thenumberofgroups, not thenumber of characters per group!
G是分組數,不是每組幾個字!
the link below have more answer:
https://github.com/morris821028/UVa/blob/master/volume111/11192 - Group Reverse.cpp