TeX中的引号~C语言

在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()
{
    char c,flag=1;
    while((c=getchar())!='\n')
    {
        if(c=='"')
        {
            if(flag)
            {
                printf("``");
                flag=0;
            }
            else
            {
                printf("''");
                flag=1;
            }
        }
        else
            printf("%c",c);
    }
     printf("\n");
    return 0;
}

猜你喜欢

转载自blog.csdn.net/mycsdn_xm/article/details/81101962