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; ...
随机推荐
- Linux负载均衡软件LVS之二(安装篇)[转]
Linux负载均衡软件LVS之二(安装篇) 2011-04-26 16:01:47 标签:lvs安装配置 linux lvs 休闲 linux高可用 原创作品,允许转载,转载时请务必以超链接形式标明文 ...
- Cocos2D-X2.2.3学习笔记12(瞬间动作)
到眼下我们已经学习了有 坐标系统 内存管理 UI系统 事件处理 几何图形 今天我们来学习动作管理OK 我们来看看类结构图 CCAction 全部动作的基类 以下派生了三个子类:CCFiniteTi ...
- Zend框架2入门(二) (转)
Zend框架2使用一个模块系统,和你组织内每个你的主应用程序特定代码模块.骨架提供的应用程序模块是用于提供引导,错误和路由配置到整个应用程序.它通常是用来提供应用水平控制器,比如说,应用程序的主页,但 ...
- JAVA/PHP/C#版RSA验签--转
本文是上一篇文章的兄弟篇,上篇文章介绍了客户端的sdk中如何基于JAVA/PHP/C#使用RSA私钥签名,然后服务端基于JAVA使用RSA公钥验签,客户端签名/服务端验签的模式只能帮助服务端检查客户端 ...
- CentOS 6.6下PXE+Kickstart无人值守安装操作系统
一.简介 1.1 什么是PXE PXE(Pre-boot Execution Environment,预启动执行环境)是由Intel公司开发的最新技术,工作于Client/Server的网络模式,支持 ...
- Linux下查看显示器输出状态以及修改显示器工作模式(复制 or 扩展)
//关闭显示器VGA1xrandr --output VGA1 --off //开启显示器VGA1xrandr --output VGA1 --auto //关闭显示器LVDS1xrandr --ou ...
- Oracle 学习笔记(一)Oracle的基本介绍与语法
1.1 Oracle基础知识 1.1.1 介绍 Oracle数据库的主要特点: 支持多用户.大事务量的事务处理 在保持数据安全性和完整性方面性能优越 支持分布式数据处理 具有可移植性 1.1.2 Or ...
- GridView and DropDownList
<form id="form1" runat="server"> <div> <asp:GridView runat=" ...
- 安卓手机内外SD卡互换
相信有許多人....有內置sd太小...外置sd(sdcard2或extsd)卻只能放資料.... 一些遊戲或者是影音播放軟體....根本不會去讀外置sd(sdcard2或extsd)..... 記憶 ...
- 在浏览器中打不开Oracle 11gR2的企业管理器页面
最简单的办法,重建EM 四个步骤: emca -repos drop emca -repos create emca -config dbcontrol db emctl start dbconsol ...