码迷,mamicode.com
首页 > 其他好文 > 详细

Tex括号(字符串处理,有陷阱)

时间:2014-09-11 19:28:12      阅读:149      评论:0      收藏:0      [点我收藏+]

标签:字符串处理专题

题目信息如下:

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


代码如下:

#include<stdio.h>
int main()
{
	int ok=1;
	char c;
	while((c=getchar())!=EOF)
	{
		if(c=='"')
		{
			printf("%s",ok?"“":"”");
			ok=!ok;
		}
		else
		putchar(c);
	}
	return 0;
}


Tex括号(字符串处理,有陷阱)

标签:字符串处理专题

原文地址:http://blog.csdn.net/ice_alone/article/details/39209151

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