【UVA272】TEX Quotes
Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld
& %llu
Description
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!''
题意:大概就是一段话里面全部的双引號编程TeX里面的左双引號和右双引號的形式
题解:一个一个字符的读入 进行推断 注意TeX区分左右双引號 用一个flag做标记
include <iostream>
#include <cstdio>
#include <cstring>
using namespace std; int main(){
char c;
bool flag = true;
while((c = getchar()) != EOF){
if(c == '"'){
if(flag){
printf("``");
flag = false;
}
else{
printf("''");
flag = true;
}
}
else{
printf("%c", c);
}
}
return 0;
}
版权声明:本文博主原创文章。博客,未经同意不得转载。
【UVA272】TEX Quotes的更多相关文章
- 【OI】Tex Quotes——UVa 272
题目: TEX is a typesetting language developed by Donald Knuth. It takes source text together with a fe ...
- 【例题3-1 UVA - 272 】TEX Quotes
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 大水题. 用一个int记录遇到的是左括号还是右括号. [错的次数] 在这里输入错的次数 [反思] 在这里输入反思 [代码] #inc ...
- UVA 272 TEX Quotes【字符串】
https://vjudge.net/problem/UVA-272 [分析]:标记一下. [代码]: #include <bits/stdc++.h> using namespace s ...
- Uva272.TEX Quotes
题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...
- 【三】用Markdown写blog的常用操作
本系列有五篇:分别是 [一]Ubuntu14.04+Jekyll+Github Pages搭建静态博客:主要是安装方面 [二]jekyll 的使用 :主要是jekyll的配置 [三]Markdown+ ...
- Python开发【前端】:jQuery
jQuery简介 jQuery是一个快速.简洁的JavaScript框架,是继Prototype之后又一个优秀的JavaScript代码库(或JavaScript框架).jQuery设计的宗旨是&qu ...
- 【wget】一条命令轻松备份博客(包括图片)
h2:first-child, body>h1:first-child, body>h1:first-child+h2, body>h3:first-child, body>h ...
- PHP5 session 详解【经典】 -- 转帖
PHP5 session 详解[经典] http协议是WEB服务器与客户端(浏览器)相互通信的协议,它是一种无状态协议.所谓无状态,指的是不会维护http请求数据,http请求是独立的,非持久的.而越 ...
- HDU 5874 Friends and Enemies 【构造】 (2016 ACM/ICPC Asia Regional Dalian Online)
Friends and Enemies Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Othe ...
随机推荐
- Mysql 导入导出数据结构及数据
方式一: mysqldump -ukevin -P3306 --default-character-set=utf8 -p -h10.1.15.123 activity sign_in_user &g ...
- ZooKeeper的安装、配置、启动和使用(一)——单机模式
ZooKeeper的安装.配置.启动和使用(一)——单机模式 ZooKeeper的安装非常简单,它的工作模式分为单机模式.集群模式和伪集群模式,本博客旨在总结ZooKeeper单机模式下如何安装.配置 ...
- OCA读书笔记(16) - 执行数据库恢复
16. Performing Database Recovery 确定执行恢复的必要性访问不同接口(EM以及命令行)描述和使用可用选项,如RMAN和Data Recovery Advisor执行恢复- ...
- csdn肿么了,这两天写的博文都是待审核
昨天早上8点写了一篇博文,然后点击发表,结果系统显示"待审核".于是仅仅好qq联系csdn的客服,等到9点时候,csdn的客服上线了,然后回复说是链接达到5个以上须要审核,于是回到 ...
- 华为C8816电信版ROOT过程
华为C8816电信版ROOT方法, 网上的方法都不太靠谱.. 昨天弄了好久, 最终搞定.. 整理了一下.. 实用到的就方便多了. <方法不再啰嗦, 都有说明> 1. 获取手机解锁passw ...
- hdu 4685 Prince and Princess(匈牙利算法 连通分量)
看了别人的题解.须要用到匈牙利算法的强连通算法 #include<cstdio> #include<algorithm> #include<vector> #pra ...
- 读书笔记:《为什么大猩猩比专家高明, How We Decide》
读书笔记:<为什么大猩猩比专家高明, How We Decide> 英文的书名叫<How We Decide>,可能是出版社的原因,非要弄一个古怪的中文书名<为什么大猩猩 ...
- SEAndroid安全机制中的进程安全上下文关联分析
前面一篇文章分析了文件安全上下文关联过程.可是在SEAndroid中,除了要给文件关联安全上下文外,还须要给进程关联安全上下文.由于仅仅有当进程和文件都关联安全上下文之后,SEAndroid安全策略才 ...
- 所有城市list每次从页面花1段时间抽取后写入到数组,
所有城市list每次从页面花1段时间抽取后写入到数组,
- POJ 1182 :食物链(并查集)
食物链 Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 43526 Accepted: 12679 Description ...