【题目描述】
传送门
【题目分析】
今天开始刷紫书的题目啦
这道题很简单,需要注意的是c=getchar()需要加上括号,因为赋值语句的优先级比判等低
而且书中说好像最好用整型变量,因为EOF的值为-1,在字符变量中没有这个值。(但是我自己写了一个测试了一下好像也没有什么问题)
【AC代码】
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<climits>
#include<queue>
#include<vector>
#include<set>
#include<map>
using namespace std;typedef long long ll;
const int INF=0x3f3f3f3f;
const int MAXN=10;int main()
{int c,p=0;while((c=getchar())!=EOF){if(c=='"'){if(p%2==0){printf("``");}else{printf("''");}p++;}else{printf("%c",c);}}return 0;
}
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<cstdlib>
#include<set>
#include<map>
#include<vector>using namespace std;typedef long long ll;
const int INF=0x3f3f3f3f;
const int MAXN=1e5+5;int main()
{
// freopen("data.in","r",stdin);
// freopen("data_test.out","w",stdout);char c;bool p=true;while((c=getchar())!=EOF){if(c=='"'){printf("%s",p?"``":"''");p=!p;}else{printf("%c",c);}}return 0;
}