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

思路:
还是得学STL,不然好多东西就是浮在表面上不能理解
这个题目也算是给解决字符串问题提供了一种思路吧,一个个的读取字符,然后再逐个的输出

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std; int main()
{
char c,flag = ;
while((c=getchar())!=EOF)
{
if(c=='"') {
printf("%s",flag?"``":"''");
flag = !flag;
}
else
printf("%c",c);
}
return ;
}

POJ-1488(字符串应用)的更多相关文章

  1. POJ 1488 Tex Quotes --- 水题

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

  2. POJ 1200 字符串HASH

    题目链接:http://poj.org/problem?id=1200 题意:给定一个字符串,字符串只有NC个不同的字符,问这个字符串所有长度为N的子串有多少个不相同. 思路:字符串HASH,因为只有 ...

  3. poj 2681 字符串

    http://poj.org/problem?id=2681 给你任意长度的字符串,找出两串字符中不相同的字符个数(总数) #include<string> #include<cst ...

  4. poj 3461 字符串单串匹配--KMP或者字符串HASH

    http://poj.org/problem?id=3461 先来一发KMP算法: #include <cstdio> #include <cstring> #include ...

  5. poj 2503(字符串)

    http://poj.org/problem?id=2503 题意:就是翻译,给你一个字典,然后再查找单词,找得到的就输出单词,找不到的输出eh,用Map水题一个,但这个题有点意思的就是输入的问题 # ...

  6. poj 3981 字符串替换

    字符串替换 Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10871   Accepted: 5100 Descriptio ...

  7. poj 2503 字符串hash

    题目链接:http://poj.org/problem?id=2503 代码: #include<cstdio> #include<cstring> #include<i ...

  8. poj 1200字符串hash

    题意:给出不同字符个数和子串长度,判断有多少个不同的子串 思路:字符串hash. 用字符串函数+map为什么会超时呢?? 代码: #include <iostream> #include ...

  9. poj 2774 字符串哈希求最长公共子串

    Long Long Message #include <iostream> #include <algorithm> #include <cstdio> #incl ...

  10. POJ 1488

    #include <iostream> #include <string> using namespace std; int main() { string s; int i; ...

随机推荐

  1. PHP Strict standards:Declaration of … should be compatible with that of…(转)

    今天把原来一份很老的PHP代码导入到了PaaS上,出现了许多Strict standards:Declaration of … should be compatible with that of…这样 ...

  2. 【解决】WordPress FTP连接服务器时出错,请检查设置,WordPress需要访问您网页服务器的权限

    刚装好wordpress,发现后台预装了两个插件,想删掉,结果要登录FTP,死活登不上去,提示"连接服务器时出错,请检查设置,WordPress需要访问您网页服务器的权限",网上也 ...

  3. 正式进入C#的世界——委托

    委托(delegate)1.可以认为是这样的对象,它包含具有相同签名和返回值类型的有序方法列表.2.可以理解为函数的一个包装,它使得C#中的函数可以作为参数来被传递. 委托的定义和方法的定义类似,只是 ...

  4. SuperSocket快速入门(一):什么是SuperSocket

    什么是SuperSocket SuperSocket(下文简称SS)是一个轻量级, 跨平台而且可扩展的 .Net/Mono Socket 服务器程序框架.你无须了解如何使用 Socket, 如何维护 ...

  5. JVM 内存分为四大块

    1.栈区 存放函数参数值和局部变量值 2.堆区 3.静态区 4.代码区

  6. mockito学习

    mockito学习 写一个测试用例,如果在测试类上面添加了注解@RunWith(SpringJUnit4ClassRunner.class),必须添加@ContextConfiguration(&qu ...

  7. IIS 7.5 配置伪静态

    IIS 7.5 配置伪静态_win服务器_脚本之家 win7下IIS的安装和配置 图文教程详细出处参考:http://www.jb51.net/article/29787.htm http://blo ...

  8. WARNING OGG-01223 TCP/IP error 111 (Connection refused)

    一:问题描述 GGSCI (source_pc) 64> info all Program     Status      Group       Lag at Chkpt  Time Sinc ...

  9. Android Fragment用法之给Activity创建事件回调

    在某些案例中,可能需要Fragment与Activity共享事件.在Fragment内部定义一个回调接口是一个好方法,并且规定由持有它的Activity实现这个回调方法.当Activity通过接口接受 ...

  10. apache2.2 虚拟主机配置详解

    一.修改httpd.conf 打开appserv的安装目录,找到httpd.conf文件,分别去掉下面两行文字前面的#号. #LoadModule vhost_alias_module modules ...