您的位置:首页 > 其它

TeX中的引号

2017-05-06 17:51 239 查看
题目描述:

           在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("%s",c);

    }

 }

 #include<stdio.h>

 #include<iostream>

 using namespace std;

 int main()

 {

     int c,flag=1;

     while((c=getchar())!=EOF)

     {

         if(c=='"')

         {

             if(flag)

                 cout<<"``";

             else

                 cout<<"''";

             flag=!flag;

             

         }

         else

         {

             cout<<char(c);

         }

     }

 }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: