phr0720 @ 2024-09-08 13:28:02
#include<bits/stdc++.h>
using namespace std;
string s;
string str;
int main() {
int q;
cin>>q;
cin>>s;
while(q--){
int op,a,b;
cin>>op;
if(op==1){
cin>>str;
s+=str;
cout<<s<<endl;
}
if(op==2){
cin>>a>>b;
s=s.substr(a,b);
cout<<s<<endl;
}
if(op==3){
cin>>a>>str;
s.insert(a,str);
cout<<s<<endl;
}
if(op==4){
cin>>str;
for(int i=1;i<=s.size();i++){
if(s.find(str)!=NULL){
cout<<s.find(str);
break;
}
else{
cout<<"-1";
return 0;
}
}
}
}
return 0;
}
by bluedemmo @ 2024-09-08 17:27:01
@phr0720
#include<bits/stdc++.h>
using namespace std;
int n;
int x;
int a,b;
string str;
string s;
int main(){
cin>>n;
cin>>s;
for(int k=1;k<=n;k++)
{
cin>>x;
if(x==1)
{
cin>>str;
s=s+str;
cout<<s<<"\n";
}
else if(x==2)
{
cin>>a>>b;
string tmp="";
for(int i=a;i<b+a;i++)
{
tmp+=s[i];
}
s=tmp;
cout<<s<<"\n";
}
else if(x==3)
{
cin>>a;
cin>>str;
string s2="",s3="";
for(int i=0;i<a;i++)
{
s2+=s[i];
}
for(int i=a;i<s.length();i++)
{
s3+=s[i];
}
s=s2+str+s3;
cout<<s<<"\n";
}
else if(x==4)
{
cin>>str;
bool f=1;
for(int i=0;i<s.length();i++)
{
// cout<<s[i]<<"|"<<str[0]<<" ";
if(s[i]==str[0])
{
string s4="";
for(int j=i;j<i+str.length();j++)
{
s4+=s[j];
}
// cout<<"*"<<s4;
if(s4==str)
{
f=0;
cout<<i<<"\n";
break;
}
}
}
if(f)cout<<-1<<"\n";
}
}
return 0;
}
回关?
by bluedemmo @ 2024-09-08 17:27:29
@phr0720
大色狼柯南?
by phr0720 @ 2024-09-08 18:50:10
@zhushengnan谢谢大佬,此题已过,谢谢,此帖结。