替换文本中的引号。
(PS为了做题方便我实现将英文替换为中文引号)
#include <iostream>
using namespace std;
int main()
{
int n;
int q=1;
while ((n=cin.get())!=EOF){
if (n=='"') {cout<<(q?"“":"”");q=!q;}
else cout<<char(n);
}
return 0;
}
设置开关变量q=1;
如果输入的(n==英文引号)则输出 中文引号。
用三目运算符判断为左引号还是右引号。
如果n不是引号则输出char(n);