题目:

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

最新文章

  1. Modify Branding of FreeCAD
  2. 第八章 交互技术,8.4 Weex 双11会场大规模应用的秒开实战和稳定性保障(作者:鬼道)
  3. Delphi在创建和使用DLL的时候如果使用到string,请引入ShareMem单元
  4. Linux下TCP网络编程与基于Windows下C#socket编程间通信
  5. 【uoj149】 NOIP2015—子串
  6. DIRECTORY_SEPARATOR 和 PATH_SEPARATOR的区别
  7. 关于Servlet中的HttpServletRequest和HttpServletResponse
  8. TMsgThread, TCommThread -- 在delphi线程中实现消息循环
  9. 对PostgreSQL中tablespace 与 database, table的理解
  10. cocos2d-x使用tinyxml2存储解析xml
  11. c# 使用递归 循环遍历导航树结构 并解析
  12. Angular4 后台管理系统搭建(9) - 用自定义angular指令,实现在服务端验证
  13. 19 子线程刷新UI runOnUiThread
  14. Binary Search(Java)(递归)
  15. springBoot 项目war包部署及改为war包后资源路径错误问题
  16. 为IONIC开发的安卓apk签名
  17. flex-shrink (适用于弹性盒模型容器子元素)
  18. JS使用onscroll、scrollTop实现图片懒加载
  19. 用原生js来处理跨域的数据(jsonp)
  20. 学JS的心路历程Day26 - PixiJS -入坑

热门文章

  1. Java-SpringBoot注解方式实现AOP
  2. Golang语言系列-03-流程控制语句
  3. Linux部署PgSQL数据库
  4. SSM自学笔记(三)
  5. 关于MYSQL5.7:Access denied for user &#39;root&#39;@&#39;localhost&#39; (using password:YES)解决
  6. ElasticSearch之配置文件详解
  7. CentOS7中apache的部署与配置
  8. 乌班图安装redis问题
  9. Win10 pip install augimg 报 OSError: [WinError 126] 找不到指定的模块,解决办法
  10. Heartbeat MySQL双主复制