プログラマメモ2 - programmer no memo2

poj 2039 2010/02/07

久しぶりにpojです。
2039 -- To and Fro
えーと、RATIOが高いもの(誰もが解けるもの...)を選んでます。


package p2039;

import java.io.IOException;
import java.util.Scanner;

public class Main {

public static void main(String[] args) throws IOException {

Scanner scanner = new Scanner(System.in);
while (scanner.hasNext()) {
int c = scanner.nextInt();
if (c == 0)
break;
String line = scanner.next();
char[] cs = line.toCharArray();
for (int i = 0; i < c; i++) {
System.out.print(cs[i]);
boolean b = true;
for (int j = c; j < cs.length; j += c) {
System.out.print(cs[b ? j + (c - (1 + i)) : j + i]);
b = !b;
}
}
System.out.println();

}
}

}

: