求大佬不吝赐教,c++代码如下:
#include<iostream>
#include<string>
using namespace std;
int main(){
int q=0;
string s="";
cin >> q ;
cin.ignore();
getline(cin,s);
int i=0;
while(i<q){
int t=0,a=0,b=0;
string str="";
cin >> t;
cin.ignore();
if(t==1){
getline(cin,str);
s+=str;
cout << s << endl;
}
if(t==2){
cin >> a >> b;
str=s.substr(a,b);
s=str;
cout << s << endl;
}
if(t==3){
cin >> a;
cin.ignore();
getline(cin,str);
s.insert(a,str);
cout << s << endl;
}
if(t==4){
int pos=0;
getline(cin ,str);
pos= s.find(str);
if(pos<s.size())
cout << pos << endl;
else
cout << -1 << endl;
}
i++;
}
return 0;
}