Sample Input
"To be or not to be," quoth the Bard, "that
is the question".
The programming contestant replied: "I must disagree.
To `C' or not to `C', that is The Question!"
Sample Output
``To be or not to be,'' quoth the Bard, ``that
is the question''.
The programming contestant replied: ``I must disagree.
To `C' or not to `C', that is The Question!''
大意: 給N個字串 要你按照規則轉換後輸出
解法: 兩個轉換的符號交替輸出
import java.util.*;
public class UVA272 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int count = 0;
String line;
while (sc.hasNext()) {
line = sc.nextLine();
for (int i = 0; i < line.length(); i++) {
if (line.charAt(i) == '"') {
if (count % 2 == 0)
System.out.print("``");
else
System.out.print("''");
count++;
}
else
System.out.print(line.charAt(i));
}
System.out.println();
}
}
}