【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 ...
随机推荐
- Android 实现环形进度按钮circular-progress-button
※效果 ※简单介绍 显示运行进度的button,可用于数据的提交.系统登录等.动画效果非常棒.提高用户体验. ※使用说明 Declare button inside your layout XML f ...
- Struts ActionForm简单理解
要想明确struts的控制流程以及它核心API的实现原理(比方 Action/DispatchAction/ActionForm的实现原理),玩转struts1.2的关键就是可以玩转 ActionFo ...
- OCA读书笔记(14) - 备份和恢复基本概念
备份恢复概念 如何判断数据库的一致性 在mount状态下,oracle如何判断数据库的一致性 scn:system change number,它是数据库时钟 如何查询当前系统的scn: select ...
- debian下使用siege进行压力测试
一:siege siege是开源的一个测试工具,可以对指定文本的URL列表进行负载测试,也可以在执行其他请求前让某个请求休眠,从而让你感觉某个用户在转移到web应用的下一个文档前正在读取该文档. ht ...
- 百度富文本编辑器UEditor1.3上传图片附件等
今天一直在整我的一个项目的编辑器上传图片,我用的是百度UEditor 1.3版本号的:如今已经有了1.4的了,只是还算比較新吧,可是官网上面没有上传图片这些的教程,而网上对于这方面的资料非常少啊,折腾 ...
- leetcode - Pascal's Triangle
Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5, Retu ...
- Mutex(测量)
游标共享怎样使用Mutex kks 使用mutex以便保护对于下述基于parent cursor父游标和子游标child cursor的一系列操作 对于父游标parent cursor的操作: 基于发 ...
- 解压system.img
解压: All-Series:~$ simg2img system.img system.img.ext4 All-Series:~$ mkdir tmp All-Series:~$ mount -t ...
- Exec l 中分列的作用
- log4net和一般的记录日志方法
下载 http://files.cnblogs.com/crazyair/log4net.zip 1 在web项目中新建一个 Log4Net.config <?xml version=" ...