本文主要是介绍UVA272 TEX Quotes【字符串处理】,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
问题描述
在Tex中,左双引号是 “ `` ”,右双引号是 “ '' ”。输入一篇包含双引号的文章,你的任务是把它转换成TeX的格式
样例输入
"To be or not to be," quoth the Bard, "that
is the question".
The programming contestant replied: "I must disagree.
To `C' or not to `C', that is The Question!"
样例输出
``To be or not to be,'' quoth the Bard, ``that
is the question''.
The programming contestant replied: ``I must disagree.
To `C' or not to `C', that is The Question!''
解题思路:简单字符串处理,问题的关键是如何把 “ '' ” 换成对应的符号,使用一个标记即可,具体看程序
AC的C语言程序:
#include<stdio.h>int main()
{int c,q=1;while((c=getchar())!=EOF){if(c=='"'){printf("%s",q?"``":"''");q=!q; }elseprintf("%c",c);}return 0;}
这篇关于UVA272 TEX Quotes【字符串处理】的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!