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; ...
随机推荐
- 机房管理系统——vb与excel链接2
因为我之前找的文档让我以为在创建表里面走了非常大的误区,所以当时我直接就在学生管理系统的目录里建了张表,执行时候直接打开这样表即可了. 可是这里面还是存在着非常大的误区. 后来我看了周坤的博客感觉他比 ...
- [AngularJS 2 实践 一]My First Angular App
最近一直在看关于AngularJS 2的资料,查看了网上和官网很多资料,接下来就根据官网教程步骤一步步搭建我的第一个Angular App AngularJS 2说明请参考:http://cnodej ...
- RollPagerView的用法:
RollPagerView的用法: /** * * @author smiling * @date 2016/10 */ Android Studio 导包: compile 'com.jude:ro ...
- Java多线程——线程的生命周期和状态控制
一.线程的生命周期 线程状态转换图: 1.新建状态 用new关键字和Thread类或其子类建立一个线程对象后,该线程对象就处于新生状态.处于新生状态的线程有自己的内存空间,通过调用start方法进入就 ...
- C#中的序列化与反序列化
眼看XX鸟的课程关于C#的知识点就要学完了,翻看网络中流传的教程还是发现了一个课程中没有讲到的知识点:序列化与反序列化 无奈还是了解一下并操作一番,以备后用吧 介绍:就是将对象信息转化为二进制信息以便 ...
- 使用Canvas实现下雪功能
示例代码: <html> <head> <meta http-equiv="Content-Type" content="text/html ...
- 遍历页面上所有TextBox,并赋值为String.Empty
//不含母板页 foreach (System.Web.UI.Control txtobj in this.Page.Controls) { if (txtobj.GetType().Na ...
- AFNetworking 3.0的GET和POST的使用
POST: AFHTTPSessionManager *session = [AFHTTPSessionManager manager]; session.requestSerializer = [A ...
- nodejs概论
我将在此写下自己读<Node.js开发指南>一书的笔记,以便于以后的学习. 一.什么是node.js Node.js 是一个让 JavaScript 运行在浏览器之外的平台. Node.j ...
- react-native-router-flux 下部导航
github url:https://github.com/aksonov/react-native-router-flux API: https://github.com/aksonov/react ...