题目链接:http://poj.org/problem?id=1488
技巧:简单的字符串替换
public static void main(String args[]) {
Scanner cin = new Scanner(System.in);
String line;
boolean flag = false;
while(cin.hasNext()){
line = cin.nextLine();
for (int i = 0; i < line.length(); i++) {
if (line.charAt(i)=='\"') {
if (flag) {
line = line.replaceFirst("\"", "''");
flag = false;
} else {
line = line.replaceFirst("\"", "``");
flag = true;
}
}
}
System.out.println(line);
}
}
网友评论