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 //分析:使用一个标志变量判断一个双引号是左双引号还是右双引号

 

 posted on 2016-03-08 15:55  tostring_char  阅读(196)  评论(0编辑  收藏  举报