TeX is a typesetting language developed by Donald Knuth. It takes source text together with a few typesetting instructions and produces, one hopes, a beautiful document. Beautiful documents use `` and " to delimit
quotations, rather than the mundane " which is what is provided by most keyboards. Keyboards typically do not have an oriented double-quote, but they do have a left-single-quote ` and a right-single-quote '. Check your keyboard now
to locate the left-single-quote key ` (sometimes called the ``backquote key") and the right-single-quote key ' (sometimes called the ``apostrophe" or just ``quote"). Be careful not to confuse the left-single-quote ` with the ``backslash"
key \. TeX lets the user type two left-single-quotes `` to create a left-double-quote `` and two right-single-quotes '' to create a right-double-quote ''. Most typists, however, are accustomed to delimiting their quotations with
the un-oriented double-quote ".

If the source contained

"To be or not to be," quoth the bard, "that is the question."

then the typeset document produced by TeX would not contain the desired form:

``To be or not to be," quoth the bard, ``that is the question."

In order to produce the desired form, the source file must contain the sequence:

``To be or not to be,'' quoth the bard, ``that is the question.''

You are to write a program which converts text containing double-quote (") characters into text that is identical except that double-quotes have been replaced by the two-character sequences required by
TeX for delimiting quotations with oriented double-quotes. The double-quote (") characters should be replaced appropriately by either `` if the " opens a quotation and by '' if the " closes a quotation. Notice that
the question of nested quotations does not arise: The first " must be replaced by ``, the next by '', the next by``, the next by '', the next by ``, the next by '', and so on.

Input and Output

Input will consist of several lines of text containing an even number of double-quote (") characters. Input is ended with an end-of-file character. The text must be output exactly as it was input except
that:

  • the first " in each pair is replaced by two ` characters: `` and
  • the second " in each pair is replaced by two ' characters: ''.

Sample Input

"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!"

Sample Output

``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代码:

#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;
}

Uva - Uva272 - TEX Quotes的更多相关文章

  1. UVa 272 Tex Quotes --- 水题

    题目大意:在TeX中,左引号是 ``,右引号是 ''.输入一篇包含双引号的文章,你的任务是把他转成TeX的格式 解题思路:水题,定义一个变量标记是左引号还是右引号即可 /* UVa 272 Tex Q ...

  2. Uva272.TEX Quotes

    题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

  3. UVA 272 TEX Quotes

    TEX Quotes 题意: 变引号. 题解: 要想进步,真的要看一本好书,紫书P45 代码: #include<stdio.h> int main() { int c,q=1; whil ...

  4. UVA 272 TEX Quotes【字符串】

    https://vjudge.net/problem/UVA-272 [分析]:标记一下. [代码]: #include <bits/stdc++.h> using namespace s ...

  5. 【UVA272】TEX Quotes

    A - TEX Quotes Time Limit:3000MS    Memory Limit:0KB    64bit IO Format:%lld & %llu Submitcid=80 ...

  6. POJ 1488 Tex Quotes --- 水题

    POJ 1488 题目大意:给定一篇文章,将它的左引号转成 ``(1的左边),右引号转成 ''(两个 ' ) 解题思路:水题,设置一个bool变量标记是左引号还是右引号即可 /* POJ 1488 T ...

  7. TEX Quotes(字符串,水)

    TEX Quotes Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 9674   Accepted: 5073 Descri ...

  8. 【OI】Tex Quotes——UVa 272

    题目: TEX is a typesetting language developed by Donald Knuth. It takes source text together with a fe ...

  9. uva 272 Tex中的引号(Tex Quotes)

    TeX is a typesetting language developed by Donald Knuth. It takes source text together with a few ty ...

随机推荐

  1. 在QEMU中调试ARM程序【转】

    转自:http://linuxeden.com/html/develop/20100820/104409.html 最近我想调试一个运行在QEMU模拟ARM系统中的Linux程序.我碰到过一些麻烦,因 ...

  2. python 类的特殊成员方法

    __doc__ # 输出类的描述信息 __module__ # 表示当前操作的对象在那个模块 __class__ # 表示当前操作的对象的类是什么 __init__ # 构造方法,通过类创建对象是,自 ...

  3. 深度学习 Fine-tune 技巧总结

    深度学习中需要大量的数据和计算资源(乞丐版都需要12G显存的GPU - -)且需花费大量时间来训练模型,但在实际中难以满足这些需求,而使用迁移学习则能有效 降低数据量.计算量和计算时间,并能定制在新场 ...

  4. Cisco Port-Channel 设置(链路聚合)

    Port-Channel 的在实际工作中的主要作用是将两个或多个端口捆绑成为一个虚拟通道. interface Port-channel1 description port(1/0/5-6) swit ...

  5. Kali安装使用文泉驿字体

    安装文泉驿字体 Kali选择"简体中文"安装后,在终端等地方发现字体总有重叠,只要安装中文字体即可,这里推荐文泉驿字体.文泉驿是一个以开发开源.免费中文电子资源--如汉字字体.词库 ...

  6. JS中的DOM— —节点以及操作

    DOM操作在JS中可以说是非常常见了吧,很多网页的小功能的实现,比如一些元素的增删操作等都可以用JS来实现.那么在DOM中我们需要知道些什么才能完成一些功能的实现呢?今天这篇文章就先简单的带大家入一下 ...

  7. 关于Allele(等位基因)的理解

    高中学生物的时候关于遗传学的部分,记得当时的教材上为了简化处理一般将基因型定义为AA, Aa, aa.其实这种抽象的理解对应付高考是很有用的,但是实际应用中如果还这样理解那么便会产生一些疑问.之所以会 ...

  8. JavaC命令不能被执行尴尬问题解决

    安装和配置环境变量都按着流程在,但在最后的检验时,发现Java   Java -version 都能运行,唯独Javac 报"不能识别命令"错误信息,下面列出我遇到一个尴尬问题 在 ...

  9. Go 语言指针

    Go 语言中指针是很容易学习的,Go 语言中使用指针可以更简单的执行一些任务. 接下来让我们来一步步学习 Go 语言指针. 我们都知道,变量是一种使用方便的占位符,用于引用计算机内存地址. Go 语言 ...

  10. JS基础速成(一)

    .t1 { background-color: #ff8080; width: 1100px; height: 40px } 一.JS的变量 1.变量的声明 var num=1;//使用var生命的变 ...