poj 3438
2011/09/10
java
pku
poj
3438 -- Look and Say Javaです。 問題文はとくに読まずにチャレンジ。
package p3438;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
while (0 < n--) {
char[] cs = scanner.next().toCharArray();
int cnt = 1;
for (int i = 0; i < cs.length; i++) {
if ( (i + 1 < cs.length) && cs[i + 1] == cs[i]) {
cnt++;
continue;
}
System.out.print(cnt + "" + cs[i]);
cnt = 1;
}
System.out.println();
}
}
}
: