A - TEX Quotes

Time Limit:3000MS    Memory Limit:0KB    64bit IO Format:%lld
& %llu

Appoint description:

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的更多相关文章

  1. 【OI】Tex Quotes——UVa 272

    题目: TEX is a typesetting language developed by Donald Knuth. It takes source text together with a fe ...

  2. 【例题3-1 UVA - 272 】TEX Quotes

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 大水题. 用一个int记录遇到的是左括号还是右括号. [错的次数] 在这里输入错的次数 [反思] 在这里输入反思 [代码] #inc ...

  3. UVA 272 TEX Quotes【字符串】

    https://vjudge.net/problem/UVA-272 [分析]:标记一下. [代码]: #include <bits/stdc++.h> using namespace s ...

  4. Uva272.TEX Quotes

    题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

  5. 【三】用Markdown写blog的常用操作

    本系列有五篇:分别是 [一]Ubuntu14.04+Jekyll+Github Pages搭建静态博客:主要是安装方面 [二]jekyll 的使用 :主要是jekyll的配置 [三]Markdown+ ...

  6. Python开发【前端】:jQuery

    jQuery简介 jQuery是一个快速.简洁的JavaScript框架,是继Prototype之后又一个优秀的JavaScript代码库(或JavaScript框架).jQuery设计的宗旨是&qu ...

  7. 【wget】一条命令轻松备份博客(包括图片)

    h2:first-child, body>h1:first-child, body>h1:first-child+h2, body>h3:first-child, body>h ...

  8. PHP5 session 详解【经典】 -- 转帖

    PHP5 session 详解[经典] http协议是WEB服务器与客户端(浏览器)相互通信的协议,它是一种无状态协议.所谓无状态,指的是不会维护http请求数据,http请求是独立的,非持久的.而越 ...

  9. 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 ...

随机推荐

  1. HDU1176:免费馅饼(DP)

    Problem Description 都说天上不会掉馅饼,但有一天gameboy正走在回家的小径上,忽然天上掉下大把大把的馅饼.说来gameboy的人品实在是太好了,这馅饼别处都不掉,就掉落在他身旁 ...

  2. object-c编程tips-timer

    object-c定时器 object-c定时器会自己主动retain当前的使用者,假设不注意调用invalidate,则非常easy引起循环引用导致内存泄露.以下的思路提供了一套还算可行的解决方式. ...

  3. Hasor:生命周期

    首先引用Wiki的介绍一下Hasor:     “Hasor是一款开源框架.它是为了解决企业模块化开发中复杂性而创建的.Hasor遵循简单的依赖.单一职责,在开发多模块企业项目中更加有调理.然而Has ...

  4. Filter基金会

    一个.总结 简单的说,Filter的作用就是拦截(Tomcat的)service(Request,Response)方法.拿到Request.Response对象进行处理.然后释放控制.继续自己主动流 ...

  5. mixpanel实验教程(2)

    六.发送邮件和推送通知 选择该用户前面的 checkbox,点击 Send A Notification button,从下拉列表中选择 Email Message/Push Notifiaction ...

  6. 2014年百度之星程序设计大赛 - 资格赛 第三题 Xor Sum

    小记:艹蛋呢, 取long long的低30,32,34位都WA, 取31位才AC. .. 思路:依据求数组中两个数异或最大值.參考 代码: #include <stdio.h> #inc ...

  7. H3C S5120交换机ACL应用的问题

    下午在S5120上ACL的时候发现不起作用,ACL如下: acl number 3001 name deny-wan-to-lan-vpn rule 0 deny ip source 10.3.0.0 ...

  8. java中HashMap在多线程环境下引起CPU100%的问题解决(转)

    最近项目中出现了Tomcat占用CPU100%的情况,原以为是代码中出现死循环,后台使用jstack做了dump,发现是系统中不合理使用HashMap导致出现了死循环(注意不是死锁). 产生这个死循环 ...

  9. js实现的侧边栏展开收缩效果

    原文地址:http://www.softwhy.com/forum.php?mod=viewthread&tid=12246 <!DOCTYPE html> <html> ...

  10. 共同发展一个以上的开发者账户多台电脑 证书 p12 型材 进出口

    1:导出相应的开发人员证书的配置文件. 2:依据相应的app id 创建配置文件. 3:打开钥匙串,把你的公布证书导出p12文件. 4:用开发人员账号导出developerprofile文件. 5:把 ...