在Tex中左双引号是``,右双引号是”。输入一篇包含双引号的文章,将其转换成Tex格式。
样例输入:''To be or not to be,''quoth the Bard,''that is the question.''
样例输出:``To be or not to be,”quoth the Bard,``that is the question.”
本题关键:判断一个引号是左引号还是右引号。
方法:设置一个标志变量。
#include<stdio.h>
int main()
{
int c,q=1;
while((c=getchar())!=EOF)
{
if(c=='"')
{
printf("%s",q?"``":"''");
q=!q; //控制标志变量开关达到输出不同引号的目的
}
else
printf("%c",&c);
}
}
浙公网安备 33010602011771号