teX中的引号

xiaoxiao2021-02-28  43

在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''

分析:使用getchar读入字符串,设置一个标记变量来判断左双引号还是右双引号

#include<stdio.h> int main() { int c, q = 1; while((c = getchar()) != EOF) { if(c == '"') { printf("%s", q ? "``" : "''"); q = !q; } else printf("%c", c); } return 0; }
转载请注明原文地址: https://www.6miu.com/read-2400027.html

最新回复(0)