Poj -1488
2015-07-02 本文已影响20人
希崽家的小哲
题目链接: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);
}
}