北邮OJ 140 字符串操作

北邮OJ 140 字符串操作

在这里插入图片描述在这里插入图片描述

#include <bits/stdc++.h>
using namespace std;

int main(){
	string c;
	while(cin>>c){
		int t;
		scanf("%d",&t);
		while(t--){
			int i,len,x;
			char temp;
			scanf("%d",&x);
			if(x==0){
				scanf("%d %d",&i,&len);
				for(int j=i,m=i+len-1;j<m;j++,m--){
					temp=c[j];
					c[j]=c[m];
					c[m]=temp;
				}
				cout<<c<<endl;
			}
			if(x==1){
				scanf("%d %d",&i,&len);
				string a;
				cin>>a;
				c.replace(i,len,a);
				cout<<c<<endl;
			}
		}
	}
}

猜你喜欢

转载自blog.csdn.net/bingkuoluo_/article/details/88808310
今日推荐