【再看细节】SDUT春季高校周赛9 Problem E——A Tale from the Dark Side of The Moon
来源:互联网 发布:亚马逊黑科技a9算法 编辑:程序博客网 时间:2024/04/30 05:42
来源:点击打开链接
题目描述冗长,很容易看不下去。。使劲读可以看出以下信息,发现是字符串替换。
1、有两个d请换成一个p
2、有ei字符串且ei前边不为c,那么换成ie.
3、pink换成floyd.
4、EOF要查找出最后一个,否则题目中别的地方发现eof也会结束,会出现wrong answer.
5、只有小写字母和空格可以算上。。
#include <iostream>#include <string>#include <ctype.h>using namespace std;int main(){while(1){string tar,res;char c;int pos=1;getline(cin,tar);for(int i=0;i<tar.size();i++){c=tar[i];if(i<tar.size()-1 && c=='d' && tar[i+1]=='d'){res+="p";i++;}else if(i<tar.size()-1 && c=='e' &&tar[i+1]=='i'&&(i==0 || tar[i-1]!='c')){res+="ie";i++;}else if(i<tar.size()-3 && c=='p' && tar[i+1]=='i'&& tar[i+2]=='n'&& tar[i+3]=='k'){res+="floyd";i+=3;}else if(i<tar.size()-2 && c=='E' && tar[i+1]=='O'&& tar[i+2]=='F'){pos=0;break;}else if(islower(c)||c==' '){res+=c;}else{c='\0';}}cout<<res<<endl;if(pos==0)break;}}
- 【再看细节】SDUT春季高校周赛9 Problem E——A Tale from the Dark Side of The Moon
- A Tale from the Dark Side of The Moon
- A Tale from the Dark Side of The Moon
- POJ_3510_A Tale from the Dark Side of the Moon
- POJ 3510 A Tale from the Dark Side of the Moon (读题死)
- POJ 3510 A Tale from the Dark Side of the Moon 可能会
- 【差一点就坑了】SDUT春季高校周赛8(SDUT2038) Problem F——数字游戏
- GYM 100247 A. The Power of the Dark Side(水~)
- 2013春季SD高校ACM周赛9(SDUT) -E
- The moon dark,the sun hard.
- Java 8 Friday: The Dark Side of Java 8
- 2013春季SD高校ACM周赛9(SDUT) -A
- the tale of us
- A dark variant of the 'Cranefly' theme
- A Voice from the Other Side
- Under The Moon——6、Spaceship to the Moon
- “The left-hand side of an assignment must be a variable” problem with charAt
- Dark Side of Cloud Storage——元数据归来
- 人月神话
- struts标签之bean:write用法
- Struts2自定义类型转换
- 关于文件的上传
- 从myesclipse查看android源码(别人写的)
- 【再看细节】SDUT春季高校周赛9 Problem E——A Tale from the Dark Side of The Moon
- Windows Form游戏局部刷新
- Java 线程池学习
- OpenCV新手
- shadow map 阴影图算法的思考
- Androd自定义Toast
- Android UI控件之RadioGroup、RadioButton
- SDL支持视频双窗口或者创建多个视频窗口
- “网宿科技杯”厦门大学第四届程序设计积分赛 热身赛