首页 > 其他 > 详细

TeX中的引号(TeX Quote, UVa 272)

时间:2015-06-17 00:41:26      阅读:292      评论:0      收藏:0      [点我收藏+]

(UVa代表弗吉尼亚大学,272是其OJ上的第272题)
在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“.
分析:
要分左右的区别,可以用一个标记flag,有空格所以不能使用是scanf(“%s”)。

#include <stdio.h>

int main()
{
    int c, flag;
    while((c = getchar()) != EOF){
        if(c == ‘"‘){
            printf("%s", flag ? "“" : "”");
            flag = !flag;
        }
        else 
            printf("%c", c);
    }
    return 0;
}

TeX中的引号(TeX Quote, UVa 272)

原文:http://blog.csdn.net/zhou554291911/article/details/46525933

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!