版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_36737934/article/details/80209470
下面贴出源码:
package cn.zimo.algorithm;
import java.util.Scanner;
/**
* TeX括号
* @author 子墨
* @date 2018年5月5日 下午8:15:31
*/
public class Demo24 {
//"To be or not to be,"quoth the Bard ,"That is the question".
public static void main(String[] args) {
String str=new Scanner(System.in).nextLine();
int count=0;
for(int i=0;i<str.length();i++) {
if(str.charAt(i)=='"') {
if(count%2==0) {
str=str.replaceFirst("\"", "“");
}else {
str=str.replaceFirst("\"", "”");
}
count++;
}
}
System.out.println(str);
}
}