此题需注意:判断是不是以” no good”结尾,no前面要多个空格,因为有可能是有个选手的名字 是 xxxno 的形式。
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
int n = sc.nextInt();
sc.nextLine();
if (n == 0) {
break;
}
char ans[][] = new char[2][(n + 1) / 2];
ans[1][(n + 1) / 2 - 1] = '-';
int a = 0;
int b = 0;
for (int i = 0; i < n; i++) {
String str = sc.nextLine();
if (str.endsWith(" no good")) {
if (i % 2 == 0) {
ans[0][i / 2] = 'X';
} else {
ans[1][i / 2] = 'X';
}
} else {
if (i % 2 == 0) {
ans[0][i / 2] = 'O';
a++;
} else {
ans[1][i / 2] = 'O';
b++;
}
}
}
for (int i = 0; i < (n + 1) / 2; i++) {
System.out.print(i + 1 + " ");
}
System.out.println("Score");
for (int i = 0; i < (n + 1) / 2; i++) {
System.out.print(ans[0][i] + " ");
}
System.out.println(a);
for (int i = 0; i < (n + 1) / 2; i++) {
System.out.print(ans[1][i] + " ");
}
System.out.println(b);
}
sc.close();
}
}