22mengqiche @ 2024-08-13 20:28:48
#include<bits/stdc++.h>
using namespace std;
int n,num;
string str,srstr;
int a,b;
int main(){
cin>>n>>str;
for(int i = 0;i < n;i++){
cin>>num;
if(num == 1){
cin>>srstr;
str = str+srstr;
cout<<str<<endl;
}
if(num == 2){
cin>>a>>b;
str = str.substr(a,b);
cout<<str<<endl;
}
if(num == 3){
cin>>a>>srstr;
str.insert(a,srstr);
cout<<str<<endl;
}
if(num == 4){
cin>>srstr;
cout<<str.find(srstr)<<endl;
}
}
}
by GrainRain25 @ 2024-08-13 20:38:51
#include<bits/stdc++.h>
using namespace std;
int n,num;
string str,srstr;
int a,b;
int main(){
cin>>n>>str;
for(int i = 0;i < n;i++){
cin>>num;
if(num == 1){
cin>>srstr;
str = str+srstr;
cout<<str<<endl;
}
if(num == 2){
cin>>a>>b;
str = str.substr(a,b);
cout<<str<<endl;
}
if(num == 3){
cin>>a>>srstr;
str.insert(a,srstr);
cout<<str<<endl;
}
if(num == 4){
cin>>srstr;
int ans= str.find(srstr);
if(ans<=100)cout<<ans<<endl;
else cout<<-1<<endl;
}
}
}
你的-1呢