小白书上的代码相对来说简单一些,另外注意TeX格式的左双引号为··
这里先贴上自己的代码:
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cctype>
#include<cassert>
using namespace std;
char *s="`1234567890-=QWERTYUIOP[]ASDFGHJKL;'ZXCVBNM,./";
#define LL long long
int main()
{
char c;
int num=1;
while((c=getchar())!=EOF)
{
if(c=='"')
{
if(num%2)
cout<<"``";
else
cout<<""";
num++;
}
else
cout<<c;
}
return 0;
}
然后是小白书的代码,主要注意他这里设置q和c的定义与输入输出的简洁性以及直接使用条件三段式输出的简洁性:
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cctype>
#include<cassert>
using namespace std;
char *s="`1234567890-=QWERTYUIOP[]ASDFGHJKL;'ZXCVBNM,./";
#define LL long long
int main()
{
int c,q=1;
while((c=getchar())!=EOF)
{
if(c =='"')
{
printf("%s",q ? "``":"''");
q=!q;
}
}
return 0;
}