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! ' '
HINT
简单的字符变量替换~
Accepted
#include<stdio.h>
int main()
{
char ch;
int flag=0;
while(scanf("%c",&ch)!=EOF)
{
if(ch=='"')
{
if(flag%2==0)
{
printf("``");
flag=1;
}
else{
printf("''");
flag=0;
}
}
else printf("%c",ch);
}
}
TEX Quotes UVA-272的更多相关文章
- 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 ...
- 【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 Quotes --- 水题
题目大意:在TeX中,左引号是 ``,右引号是 ''.输入一篇包含双引号的文章,你的任务是把他转成TeX的格式 解题思路:水题,定义一个变量标记是左引号还是右引号即可 /* UVa 272 Tex Q ...
- UVA 272 TEX Quotes
TEX Quotes 题意: 变引号. 题解: 要想进步,真的要看一本好书,紫书P45 代码: #include<stdio.h> int main() { int c,q=1; whil ...
- Uva272.TEX Quotes
题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...
- 【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 ...
- uva 272 Tex中的引号(Tex Quotes)
TeX is a typesetting language developed by Donald Knuth. It takes source text together with a few ty ...
随机推荐
- 微信小程序:页面生命周期
小程序生命周期分为应用生命周期和页面生命周期 1.Onload:页面加载时触发,一般在onLoad中发送异步请求来初始化页面数据. 2.onShow:页面显示时触发 3.onReady:页面初次渲染完 ...
- 使用Docker创建MongoDb服务
使用Docker创建MongoDb服务 1.先拉mongodb镜像 docker pull mongodb:4.2.5 2.创建映射目录 创建mongo映射目录,用于存放后面的相关东西. mkdir ...
- 使用Tomcat30分钟搭建个人服务器
目录 一.服务器简介 二.安装教程 三.出现的问题 一.服务器简介 Tomcat服务器是一个Apache软件资金会的开源项目,实现了Servlet,JSP,EL,WebSocket协议. 二.安装教程 ...
- rabbitmq如何保证消息可靠性不丢失
目录 生产者丢失消息 代码模拟 事务 confirm模式确实 数据退回监听 MQ事务相关软文推荐 MQ丢失信息 消费者丢失信息 之前我们简单介绍了rabbitmq的功能.他的作用就是方便我们的消息解耦 ...
- hiho一下 第195周 奖券兑换[C solution][Accepted]
时间限制:20000ms 单点时限:1000ms 内存限制:256MB 描述 小Hi在游乐园中获得了M张奖券,这些奖券可以用来兑换奖品. 可供兑换的奖品一共有N件.第i件奖品需要Wi张奖券才能兑换到, ...
- 漏洞复现-fastjson1.2.24-RCE
0x00 实验环境 攻击机:Win 10.Win Server2012 R2(公网环境,恶意java文件所在服务器) 靶机也可作为攻击机:Ubuntu18 (公网环境,docker ...
- SQL练习——LeetCode解题和总结(1)
只用于个人的学习和总结. 178. Rank Scores 一.表信息 二.题目信息 对上表中的成绩由高到低排序,并列出排名.当两个人获得相同分数时,取并列名次,且名词中无断档. Write a SQ ...
- Codeforces Round #558 B2. Cat Party (Hard Edition)
题面: 传送门 题目描述: 题意:确定最大的x,使去除掉前x天的其中一天后,所有不同数字的数量相等. 题目分析: 可能是我太久没打cf了,水题都做不出来. 这道题的关键在于:要记录相同数量,的不同 ...
- python爬虫加定时任务,制作微信提醒备忘录
一.任务的记录与提取 1.1 制作每日任务 为了便于爬取,推荐使用网页版的在线记事本,现在这种工具很多,我选择"石墨文档"进行操作演示.记录内容的 格式可以根据自己的需求和爬虫自行 ...
- 关于java的访问修饰符权限
作用域 public protected default private 同一个类 yes yes yes yes 同一个包 yes yes ...