码迷,mamicode.com
首页 > 编程语言 > 详细

《算法竞赛入门经典》5.12TeX括号

时间:2016-03-08 16:39:22      阅读:440      评论:0      收藏:0      [点我收藏+]

标签:

 1 /*
 2 *在TeX中,左双引号是``,右双引号是‘‘。输入一篇包含双引号的文章,你的任务是把它转换成TeX的格式。
 3 *样例输入:"To be or not to be,"quoth the Bard,"that
 4 *is the question".
 5 *样例输出:``To be or not to be,‘‘quoth the Bard,``that
 6 *is the question.
 7 */
 8 #include <stdio.h>
 9 
10 int main()
11 {
12     int c, q = 1;
13     while((c = getchar()) != EOF)
14     {
15         if(c == ") {printf("%s", q ? "``" : "‘‘"); q = !q;}
16         else printf("%c", c);
17     }
18     return 0;
19 }
20 //分析:使用一个标志变量判断一个双引号是左双引号还是右双引号

 

《算法竞赛入门经典》5.12TeX括号

标签:

原文地址:http://www.cnblogs.com/zhuangwei/p/5254399.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!