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 double-left-quote and double-right-quote 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!''

简单来说……就是把这样的引号:

"

改成

``

或者

''

这样的。

紫书上面(UVA272)原题。

 #include<stdio.h>
int main()
{
char c;int flag=;
while((c=getchar())!=EOF){
if(c=='"'){
if(flag==) {printf("``");flag=-flag;}
else if(flag==) {printf("''");flag=-flag;}
}else{
printf("%c",c);
}
}
}

当然……紫书上面的就很很很简洁……膜拜一下……

POJ 1488 - TEX Quotes的更多相关文章

  1. POJ 1488 Tex Quotes --- 水题

    POJ 1488 题目大意:给定一篇文章,将它的左引号转成 ``(1的左边),右引号转成 ''(两个 ' ) 解题思路:水题,设置一个bool变量标记是左引号还是右引号即可 /* POJ 1488 T ...

  2. UVa 272 Tex Quotes --- 水题

    题目大意:在TeX中,左引号是 ``,右引号是 ''.输入一篇包含双引号的文章,你的任务是把他转成TeX的格式 解题思路:水题,定义一个变量标记是左引号还是右引号即可 /* UVa 272 Tex Q ...

  3. UVA 272 TEX Quotes

    TEX Quotes 题意: 变引号. 题解: 要想进步,真的要看一本好书,紫书P45 代码: #include<stdio.h> int main() { int c,q=1; whil ...

  4. Uva272.TEX Quotes

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

  5. TEX Quotes(字符串,水)

    TEX Quotes Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 9674   Accepted: 5073 Descri ...

  6. 【UVA272】TEX Quotes

    A - TEX Quotes Time Limit:3000MS    Memory Limit:0KB    64bit IO Format:%lld & %llu Submitcid=80 ...

  7. Uva - Uva272 - TEX Quotes

    TeX is a typesetting language developed by Donald Knuth. It takes source text together with a few ty ...

  8. uva 272 Tex中的引号(Tex Quotes)

    TeX is a typesetting language developed by Donald Knuth. It takes source text together with a few ty ...

  9. TeX中的引号(Tex Quotes, UVa 272)

    在TeX中,左双引号是“``”,右双引号是“''”.输入一篇包含双引号的文章,你的任务是 把它转换成TeX的格式. 样例输入: "To be or not to be," quot ...

随机推荐

  1. s3cmd用法总结

    概述 S3是亚马逊AWS提供的简单存储服务(可以理解为有公网域名的大容量高可用存储) S3配合CloudFront服务可作为CDN使用,它提供多节点全球发布 安装 方法一: yum install s ...

  2. SpringCloud服务间调用

    SpringCloud服务间的调用有两种方式:RestTemplate和FeignClient.不管是什么方式,他都是通过REST接口调用服务的http接口,参数和结果默认都是通过jackson序列化 ...

  3. 11G新特性 -- 块介质恢复性能增强(block media recovery)

    块介质恢复性能增强(block media recovery) :只是恢复受损的块.不需要将受损的数据文件offline.针对受损的数据块,使用备份中好的数据块进行restore和recover,避免 ...

  4. 腾讯云SpringBoot部署 + HTTPS配置

    springboot可以打包为jar和war,jar不多说了,最近的一个工程需要打包为war发布,大致说一下吧: 先看一下项目的大致结构: 第一步,需要排除springboot自带的tomcat插件 ...

  5. 最好的Python机器学习库

    参考链接:http://www.csdn.net/article/2015-12-10/2826435

  6. hdoj:2034

    #include <iostream> #include <vector> #include<algorithm> //包含sort函数 using namespa ...

  7. Java如何获取URL的部分?

    在Java编程中,如何获取URL的一部分? 以下示例显示了如何通过net.URL类的url.getProtocol()和url.getFile()方法等获取URL的部分. package com.yi ...

  8. 【Oracle】ORA 01810 格式代码出现两次-转

    一.Oracle中使用to_date()时格式化日期需要注意格式码 如:select to_date('2005-01-01 13:14:20','yyyy-MM-dd HH24:mm:ss') fr ...

  9. 最全面的Spring-Boot-Cache使用与整合

    一:Spring缓存抽象 Spring从3.1开始定义了org.springframework.cache.Cache和org.springframework.cache.CacheManager接口 ...

  10. thinkphp5 memcached 安装、调用、链接

    环境 linux  memcached1.5.9 (memcached安装在虚拟机192.168.70.164) wampserver集成环境 thinkphp5 php7 步骤一:linux安装me ...