Uva - Uva272 - TEX Quotes
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;
- }
- #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的更多相关文章
- UVa 272 Tex Quotes --- 水题
题目大意:在TeX中,左引号是 ``,右引号是 ''.输入一篇包含双引号的文章,你的任务是把他转成TeX的格式 解题思路:水题,定义一个变量标记是左引号还是右引号即可 /* UVa 272 Tex Q ...
- Uva272.TEX Quotes
题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...
- UVA 272 TEX Quotes
TEX Quotes 题意: 变引号. 题解: 要想进步,真的要看一本好书,紫书P45 代码: #include<stdio.h> int main() { int c,q=1; whil ...
- UVA 272 TEX Quotes【字符串】
https://vjudge.net/problem/UVA-272 [分析]:标记一下. [代码]: #include <bits/stdc++.h> using namespace s ...
- 【UVA272】TEX Quotes
A - TEX Quotes Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu Submitcid=80 ...
- POJ 1488 Tex Quotes --- 水题
POJ 1488 题目大意:给定一篇文章,将它的左引号转成 ``(1的左边),右引号转成 ''(两个 ' ) 解题思路:水题,设置一个bool变量标记是左引号还是右引号即可 /* POJ 1488 T ...
- TEX Quotes(字符串,水)
TEX Quotes Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 9674 Accepted: 5073 Descri ...
- 【OI】Tex Quotes——UVa 272
题目: TEX is a typesetting language developed by Donald Knuth. It takes source text together with a fe ...
- uva 272 Tex中的引号(Tex Quotes)
TeX is a typesetting language developed by Donald Knuth. It takes source text together with a few ty ...
随机推荐
- [BZOJ]1017 魔兽地图DotR(JSOI2008)
BZOJ第一页做着做着就能碰到毒题,做到BZOJ1082小C就忍了,没想到下一题就是这种东西.这种题目不拖出来枭首示众怎么对得起小C流逝的青春啊. Description DotR (Defense ...
- [bzoj4151][AMPPZ2014]The Cave
来自FallDream的博客,未经允许,请勿转载,谢谢. 给定一棵有n个节点的树,相邻两点之间的距离为1. 请找到一个点x,使其满足所有m条限制,其中第i条限制为dist(x,a[i])+dist(x ...
- Mysql--七种 Join 查询
Mysql 系列文章主页 =============== 1 准备数据 1.1 建立 Employee 表 DROP TABLE IF EXISTS employee; CREATE TABLE IF ...
- Button 使用Command 按钮置灰未更新
当Button绑定了Command,按钮在窗口弹出.或者其它事件时,会自动置灰. 有时,异步执行时间较长时,界面一些绑定了命令的Button,State不会变化,会一直置灰. 直到再次转移Focus. ...
- [HCNA]VLAN配置Trunk接口
实验目的 1.掌握Trunk端口的配置 2.掌握Trunk端口允许所有VLAN通过的配置方法 3.掌握Trunk端口允许特定VLAN通过的配置方法 4.理解干道链路的应用场景 实验仪器 eNSP 实验 ...
- 中间件——canal小记
接到个小需求,将mysql的部分数据增量同步到es,但是不仅仅是使用canal而已,整体的流程是mysql>>canal>>flume>>kafka>> ...
- 工作流引擎 Flowable 6.0.0.RC1 release,完全兼容Activi
Flowable 6.0.0.RC1 release,第一个可流动的6引擎版本(6.0.0.RC1). Flowable 6.0.0.RC1 relase新增加的功能以及特色: 包重命名为org.Fl ...
- POSIX 消息队列相关问题
一.查看和删除消息队列要想看到创建的posix消息队列,需要在root用户下执行以下操作:# mkdir /dev/mqueue# mount -t mqueue none /dev/mqueue删除 ...
- springMVC源码分析--ModelFactory
ModelFactory是用来维护Model的,具体包含两个功能 (1)初始化Model (2)处理器执行后将Model中相应的参数更新到SessionAttributes中 1.初始化Model其实 ...
- Bootstrap3 栅格系统-媒体查询
在栅格系统中,我们在 Less 文件中使用以下媒体查询(media query)来创建关键的分界点阈值. /* 超小屏幕(手机,小于 768px) */ /* 没有任何媒体查询相关的代码,因为这在 B ...