问题描述
在Tex中,左双引号是 “ `` ”,右双引号是 “ '' ”。输入一篇包含双引号的文章,你的任务是把它转换成TeX的格式
样例输入
"To be or not to be," quoth the Bard, "that
is the question".
The programming contestant replied: "I must disagree.
To `C' or not to `C', that is The Question!"
样例输出
``To be or not to be,'' quoth the Bard, ``that
is the question''.
The programming contestant replied: ``I must disagree.
To `C' or not to `C', that is The Question!''
解题思路:简单字符串处理,问题的关键是如何把 “ '' ” 换成对应的符号,使用一个标记即可,具体看程序
AC的C语言程序:
#include<stdio.h>
int main()
{
int c,q=1;
while((c=getchar())!=EOF)
{
if(c=='"')
{
printf("%s",q?"``":"''");
q=!q;
}
else
printf("%c",c);
}
return 0;
}