TeX中的引号(UVa272)

 

问题:

在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''.

 

分析:对输入的字符串一个一个字符进行判断,不进行存储

C++11代码如下:

 1 #include<iostream>
 2 using namespace std;
 3 int main() {
 4     int c;  // int型,因为getchar()返回的为int型
 5     bool p = true;
 6     while ((c = getchar()) != EOF) {
 7         if (c == '"') {
 8             cout << (p ? "``" : "''");
 9             p=!p;
10         }
11         else cout << char(c); //输出时转换为字符型
12     }
13     return 0;
14 }

原文链接: https://www.cnblogs.com/pgzhang/p/9221707.html

欢迎关注

微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍

    TeX中的引号(UVa272)

原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/276564

非原创文章文中已经注明原地址,如有侵权,联系删除

关注公众号【高性能架构探索】,第一时间获取最新文章

转载文章受原作者版权保护。转载请注明原作者出处!

(0)
上一篇 2023年2月15日 上午1:49
下一篇 2023年2月15日 上午1:51

相关推荐