【OI】Tex Quotes——UVa 272
题目:
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
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.
Output
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!''
解:
#include <stdio.h> int main()
{
int c,q = 1; // q为标志变量,为1时左引号,反之右引号
while ((c = getchar()) != EOF) //一直读取一个字符直到文件末尾
{
if (c == '"')
{
//换引号然后更换标志变量的值
printf("%s",q ? "``":"''");
q = !q;
}
else
{
printf("%c",c);
}
}
return 0;
}
https://vjudge.net/problem/UVA-272
【OI】Tex Quotes——UVa 272的更多相关文章
- 【UVA272】TEX Quotes
A - TEX Quotes Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu Submitcid=80 ...
- TeX中的引号(Tex Quotes, UVa 272)
在TeX中,左双引号是“``”,右双引号是“''”.输入一篇包含双引号的文章,你的任务是 把它转换成TeX的格式. 样例输入: "To be or not to be," quot ...
- 例题3_1 TeX中的引号(TeX Quotes,UVa 272)
在TeX中,左双引号是“``”,右双引号是“''”.输入一篇包含双引号的文章,你的任务是把它转换成TeX的格式. 样例输入: "To be or not to be,"quoth ...
- 【例题3-1 UVA - 272 】TEX Quotes
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 大水题. 用一个int记录遇到的是左括号还是右括号. [错的次数] 在这里输入错的次数 [反思] 在这里输入反思 [代码] #inc ...
- 【OI】计算分子量 Molar mass UVa 1586 题解
题目:(由于UVa注册不了,还是用vjudge) https://vjudge.net/problem/UVA-1586 详细说明放在了注释里面.原创. 破题点在于对于一个元素的组合(元素+个数),只 ...
- 【OI】WERTYU UVa 10082
题目: A common typing error is to place the hands on the keyboard one row to the right of the correct ...
- 【暑假】[深入动态规划]UVa 1627 Team them up!
UVa 1627 Team them up! 题目: Team them up! Time Limit: 3000MS Memory Limit: Unknown 64bit IO Forma ...
- 【暑假】[深入动态规划]UVa 1628 Pizza Delivery
UVa 1628 Pizza Delivery 题目: http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=51189 思路: ...
- 【暑假】[深入动态规划]UVa 1380 A Scheduling Problem
UVa 1380 A Scheduling Problem 题目: http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=41557 ...
随机推荐
- Java-Stream流方法学习及总结
1 前言 Stream是一个来自数据源的元素队列并支持聚合操作,其中具有以下特性: Stream只负责计算,不存储任何元素,元素是特定类型的对象,形成一个队列 数据源可以实集合.数组.I/O chan ...
- Linux下MySQL多实例部署记录
什么是MySQL多实例 简单地说,Mysql多实例就是在一台服务器上同时开启多个不同的服务端口(3306.3307),同时运行多个Mysql服务进程,这些服务进程通过不同的socket监听不同的服务端 ...
- 适配Android4.4~Android11,调用系统相机,系统相册,系统图片裁剪,转换文件(对图片进行上传等操作)
前言 最近Android对于文件的许多方法进行了修改,网络上又没有对Android4到Android11关于系统相机.系统相册和系统裁剪的适配方案,我花了几天事件总结了一下,先上源码 DEMO源码 先 ...
- 【原创】Spring Data Redis <=2.0.3反序列化漏洞
Spring Data Redis隶属于Spring Data家族, 提供简单易用的方式来访问Redis缓存. Spring Data Redis在往Redis里面写数据的时候,默认会先对数据进行序列 ...
- Upfile的几种常见姿势
记录一下文件上传的常见姿势,更全面的可以做upload-labs. 实验环境:win2003 phpstudy 实验平台:upfile 一.准备上传的一句话木马 eval函数将接受的字符串当做代码执行 ...
- NOIP 模拟 $22\; \rm f$
题解 \(by\;zj\varphi\) 对于一个数,如果它二进制下第 \(i\) 位为 \(1\),那么 \(\rm x\) 在这一位选 \(1\) 的贡献就是和它不同的最高为为 \(i\) 的数的 ...
- The Programmer's Oath程序员的誓言----鲍勃.马丁大叔(Bob Martin)
In order to defend and preserve the honor of the profession of computer programmers, I Promise that, ...
- 【转】关于DNS不得不说的一些事
转自:https://www.cnblogs.com/rjzheng/p/11395695.html 引言 今天我们来聊聊DNS.所谓域名系统(Domain Name System缩写DNS,Doma ...
- vue 基础入门(一)
app-1 :声明式渲染 app-2 :绑定元素特性 v-bind 特性被称为指令.指令带有前缀 v-,以表示它们是 Vue 提供的特殊特性. app-3 app-4 :条件与循环 app-5 ,ap ...
- 3k+2形式的素数相关的两个命题的证明