在TeX中,左双引号是“
”,右双引号是“''”。输入一篇包含双引号的文章,你的任务是把它转换为TeX的格式。 样例输入: "To be ro not to be,"quoth the Bard,"that is the question". 样例输出:
To be or not to be,''quoth the Bard,``that is the question''.
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
boolean mark = true;
while(in.hasNextLine()) {
String str = in.nextLine();
for(int i = 0; i < str.length(); i++) {
if(str.charAt(i) == '"') {
if(mark) {
System.out.print("``");
mark = false;
}else {
System.out.print("''");
mark = true;
}
}else {
System.out.print(str.charAt(i));
}
}
System.out.println();
}
}
}