FYH666666 @ 2024-07-19 18:41:13
#include<bits/stdc++.h>
using namespace std;
char str[5000];
int q;
int main(){
freopen("1.in","r",stdin);
freopen("1.out","w",stdout);
scanf("%d",&q);
scanf("%s",str);
int len=strlen(str);
for(int i=1;i<=q;i++){
int a;
scanf("%d",&a);
if(a==1){
char str2[100005];
scanf("%s",str2);
int len2=strlen(str2);
for(int i=len;i<len+len2;i++) str[i]=str2[i-len];
len+=len2;
printf("%s\n",str);
continue;
}
else if(a==2){
int a1,a2;
scanf("%d%d",&a1,&a2);
for(int i=0;i<a2;i++) str[i]=str[i+a1];
len=a2;
str[len]='\0';
printf("%s\n",str);
continue;
}
else if(a==3){
int a1;
char str2[10005];
scanf("%d%s",&a1,str2);
strcat(str2,&str[a1]);
str[a1]='\0';
strcat(str,str2);
printf("%s\n",str);
continue;
}
else if(a==4){
bool sum=0,sum2=0;
char str2[10005];
scanf("%d",str2);
for(int i=0;i<len;i++){
if(str[i]!=str2[0]) continue;
for(int j=i,k=0;j<strlen(str2),k<strlen(str2);k++,j++){
if(str[j]=str2[k]) continue;
else{
sum=1;
break;
}
}
if(sum==1) continue;
else{
printf("%d\n",i);
sum2=1;
break;
}
}
if(sum2==0) printf("-1\n");
}
}
return 0;
}
by __F__ @ 2024-07-19 18:44:42
@FYH666666
仅供参考
#include<bits/stdc++.h>
using namespace std;
int a,c;
string b,d;
int main(){
cin>>a>>b;
for(int i=1;i<=a;i++){
cin>>c;
switch(c) {
case 1: {
cin>>d;
b+=d;
cout<<b<<endl;
break;
}
case 2: {
int x1,x2;
cin>>x1>>x2;
b=b.substr(x1,x2);
cout<<b<<endl;
break;
}
case 3: {
int x1;
cin>>x1>>d;
b.insert(x1,d);
cout<<b<<endl;
break;
}
case 4: {
cin>>d;
if(b.find(d)<b.size()) cout<<b.find(d)<<endl;
else cout<<-1<<endl;
break;
}
}
}
return 0;
}
求关qwq
by Sun_ZZZ @ 2024-07-19 18:48:21
Aaaa...这道题正常输入就行,不需要用到文件
by FYH666666 @ 2024-07-19 19:12:43
@Sun_ZZZ 改了也不对