题目:

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!''

解:

#include <stdio.h>

int main()
{
int c,q = 1;  // q为标志变量,为1时左引号,反之右引号
while ((c = getchar()) != EOF)  //一直读取一个字符直到文件末尾
{
if (c == '"')
{  
       //换引号然后更换标志变量的值

printf("%s",q ? "``":"''");
q = !q;
}
else
{
printf("%c",c);
}
}
return 0;
}

https://vjudge.net/problem/UVA-272

【OI】Tex Quotes——UVa 272的更多相关文章

  1. 【UVA272】TEX Quotes

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

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

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

  3. 例题3_1 TeX中的引号(TeX Quotes,UVa 272)

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

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

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

  5. 【OI】计算分子量 Molar mass UVa 1586 题解

    题目:(由于UVa注册不了,还是用vjudge) https://vjudge.net/problem/UVA-1586 详细说明放在了注释里面.原创. 破题点在于对于一个元素的组合(元素+个数),只 ...

  6. 【OI】WERTYU UVa 10082

    题目: A common typing error is to place the hands on the keyboard one row to the right of the correct ...

  7. 【暑假】[深入动态规划]UVa 1627 Team them up!

    UVa 1627 Team them up! 题目: Team them up! Time Limit: 3000MS   Memory Limit: Unknown   64bit IO Forma ...

  8. 【暑假】[深入动态规划]UVa 1628 Pizza Delivery

    UVa 1628 Pizza Delivery 题目: http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=51189 思路:    ...

  9. 【暑假】[深入动态规划]UVa 1380 A Scheduling Problem

     UVa 1380 A Scheduling Problem 题目: http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=41557 ...

随机推荐

  1. Linux命令(五)之service服务查找、启动/停止等相关操作

    .personSunflowerP { background: rgba(51, 153, 0, 0.66); border-bottom: 1px solid rgba(0, 102, 0, 1); ...

  2. Compile Java Codes in Linux Shell instead of Ant Script

    The following is frequently used ant script, compile some java source codes with a libary path, then ...

  3. make CLI Comfortable When Working in Multiple Directoies

    alias alias is command-line counterpart of hotstring of AutoHotkey, for example: alias vboat='vi ~/d ...

  4. go配置私有仓库 (go mod配置私有仓库)

    windows 配置go私有仓库 一.环境 1.私有gitlab (gitlab.xxx.com) 2.go 1.16.3 3.win10系统, 家目录:C:\Users\Administrator, ...

  5. contos7 安装weblogic10.3 _wls1036_generic.jar

    环境:CentOS7+jdk1.8 weblogic下载地址1: http://www.oracle.com/technetwork/cn/middleware/weblogic/downloads/ ...

  6. Ubuntu时间有误差,设置系统时间与网络时间同步

    转载地址:https://blog.csdn.net/qq_33733970/article/details/78823620

  7. SpringBoot自定义请求参数转换器

    需求 我们可能对接客户的系统的时候,虽然Spring为我们提供的很多方便的转换器,但是遇到还是可能遇到需要自定义请求参数转换器的情况. 日期转换器 SpringBoot默认是没有配置日期转换器的我们可 ...

  8. js随机显示图片

    定义一个图片数组,生成一个随机数对应数据索引. window.onload = choosePic; function choosePic() { var myPix = new Array(&quo ...

  9. 【java虚拟机】内存分配与回收策略

    作者:平凡希 原文地址:https://www.cnblogs.com/xiaoxi/p/6557473.html 前言 对象的内存分配,往大的方向上讲,就是在堆上分配,少数情况下也可能会直接分配在老 ...

  10. 关于Ubuntu18.04 linux系统使用搜狗输入法 出现乱码

    解决: 执行下面的命令即可!无需重启系统 killall fcitx