POJ-1488(字符串应用)
Description
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
of double-quote (") characters. Input is ended with an end-of-file
character.
Output
- 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(字符串应用)的更多相关文章
- POJ 1488 Tex Quotes --- 水题
POJ 1488 题目大意:给定一篇文章,将它的左引号转成 ``(1的左边),右引号转成 ''(两个 ' ) 解题思路:水题,设置一个bool变量标记是左引号还是右引号即可 /* POJ 1488 T ...
- POJ 1200 字符串HASH
题目链接:http://poj.org/problem?id=1200 题意:给定一个字符串,字符串只有NC个不同的字符,问这个字符串所有长度为N的子串有多少个不相同. 思路:字符串HASH,因为只有 ...
- poj 2681 字符串
http://poj.org/problem?id=2681 给你任意长度的字符串,找出两串字符中不相同的字符个数(总数) #include<string> #include<cst ...
- poj 3461 字符串单串匹配--KMP或者字符串HASH
http://poj.org/problem?id=3461 先来一发KMP算法: #include <cstdio> #include <cstring> #include ...
- poj 2503(字符串)
http://poj.org/problem?id=2503 题意:就是翻译,给你一个字典,然后再查找单词,找得到的就输出单词,找不到的输出eh,用Map水题一个,但这个题有点意思的就是输入的问题 # ...
- poj 3981 字符串替换
字符串替换 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 10871 Accepted: 5100 Descriptio ...
- poj 2503 字符串hash
题目链接:http://poj.org/problem?id=2503 代码: #include<cstdio> #include<cstring> #include<i ...
- poj 1200字符串hash
题意:给出不同字符个数和子串长度,判断有多少个不同的子串 思路:字符串hash. 用字符串函数+map为什么会超时呢?? 代码: #include <iostream> #include ...
- poj 2774 字符串哈希求最长公共子串
Long Long Message #include <iostream> #include <algorithm> #include <cstdio> #incl ...
- POJ 1488
#include <iostream> #include <string> using namespace std; int main() { string s; int i; ...
随机推荐
- [Angular 2] Get start with Firebase
Create a Firebase Servcie: import {Injectable} from 'angular2/core'; import {Http, Response} from 'a ...
- 生成唯一的id(转)
很多朋友都利用md5()来生成唯一的编号,但是md5()有几个缺点:1.无序,导致数据库中排序性能下降.2.太长,需要更多的存储空间.其实PHP中自带一个函数来生成唯一的id,这个函数就是uniqid ...
- ERROR<53761> - Plugins - conn=-1 op=-1 msgId=-1 - Connection Bind through PTA failed (91). Retrying...
LDAP6.3在DSCC控制台启动实例完成,但是操作状态显示“意外错误”,查看日志如下: 04/May/2016:21:10:39 +0800] - Sun-Java(tm)-System-Direc ...
- divmod(a,b)函数
python每日一函数 - divmod数字处理函数 divmod(a,b)函数 中文说明: divmod(a,b)方法返回的是a//b(除法取整)以及a对b的余数 返回结果类型为tuple 参数: ...
- nyoj 44
//nyoj 44 //和上面一题一样,求子串和,但是代码非常简洁..... 时间复杂度为n #include <iostream> using namespace std; int ma ...
- Hyper-V的三种网卡
External ======= 虚拟机和物理网络.本地主机都能通信 Internal ======= 虚拟机之间互相通信,并且虚拟机能和本机通信 Private ======= 仅允许运行在这台物理 ...
- 遍历页面上所有TextBox,并赋值为String.Empty
//不含母板页 foreach (System.Web.UI.Control txtobj in this.Page.Controls) { if (txtobj.GetType().Na ...
- curl 命令使用
1.开启gzip请求curl -I http://www.sina.com.cn/ -H Accept-Encoding:gzip,defalte 2.监控网页的响应时间curl -o /dev/nu ...
- Php GMP
GMP是The GNU MP Bignum Library,是一个开源的数学运算库,它可以用于任意精度的数学运算,包括有符号整数.有理数和浮点数.它本身并没有精度限制,只取决于机器的硬件情况. 本函数 ...
- 高放的c++学习笔记之关联容器
标准库提供8个关联容器 按关键字有序保存有(红黑树实现) set map multset 关键字可重复出现的set multimap 关键字可重复出现的map 无序保存 哈希实现 unorderre ...