LHL算法入门经典 5.1.2 TeX括号

5.1.2 TeX括号

5.1.2

TeX括号 在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>
#include<math.h>
#include<string.h>

int main()
{
	int c,q=1;
	while((c=getchar())!=EOF)
	{
		if(c=='"')
		{
			printf("%s",q?"“":"”");
			q=!q;
		
		}
			else printf("%c",c);
	}
	
	
	return 0;
}
发布了33 篇原创文章 · 获赞 14 · 访问量 620

猜你喜欢

转载自blog.csdn.net/Simple_questions/article/details/105009969