北京邮电1177,replace和reverse的用法
2016-03-08 15:11
369 查看
#include<iostream> #include<cstdio> #include<string> #include<cstring> #include<algorithm> using namespace std; int main(){ string str; int n; string demand; while(cin>>str){ scanf("%d",&n); for(int i = 1;i<=n;i++) { cin>>demand; if(demand[0]=='0')//翻转 { int start = demand[1]-'0'; int len = demand[2]-'0'; reverse(str.begin()+start,str.begin()+start+len); cout<<str<<endl; }else if(demand[0]=='1')//替换 { int start = demand[1]-'0'; int len = demand[2]-'0'; string aa = demand.substr(3,len); str = str.replace(start,len,aa); cout<<str<<endl; } } } }
相关文章推荐
- c# 与 PHP中 SHA1加密结果不同解决方法
- 【移动适配】移动Web怎么做屏幕适配(三)
- 类中的方法调用
- Java IDE中设置作者日期等Javadoc注释信息
- SVD奇异值分解
- iOS开发笔记--iOS之轻松上手block
- libevent---主要函数
- 云数据中心网络虚拟化——大二层技术巡礼之控制平面一虚多
- 面试以及被面试
- iphone 设备判断
- CSV文件一键生成CSharp文件
- 设计模式六大原则(4):接口隔离原则
- JS三目运算(三元运算)
- Ubuntu-Python2.7安装 scipy,numpy,matplotlib (转)
- 自动去除nil的NSDictionary和NSArray构造方法
- 黑盒测试和白盒测试
- Storm 集群安装配置
- 怎么在cmd下运行Tomcat里的项目
- IOS学习之:网络数据的XML解析
- Android studio 导入eslipce工程(JNI多个so的情况 或者 普通工程)