https://uva.onlinejudge.org/index.php?option=onlinejudge&page=show_problem&problem=2133
這題是2016 10/04 CPE第一題,第一個數字是要把字串切割成幾等分,內迴圈從後面讀取印出來
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
while(scn.hasNext()){
int n=scn.nextInt();
if(n==0)break;
char arr[]=scn.nextLine().trim().toCharArray();
for(int i=arr.length/n-1;i<arr.length;i+=arr.length/n){
for(int j=0;j<arr.length/n;j++){
System.out.print(arr[i-j]);
}
}System.out.println();
}
}
/*題目:Q:11192 - Group Reverse
作者:1010
時間:西元 2016 年 10 月 */
}