lgwwj @ 2024-12-08 12:46:31
#include<stdio.h>
#include<string.h>
int main()
{
int n,n1;
char q,num[1000];
scanf("%d%c",&n,&q);
fgets(num,sizeof(num),stdin);
if(num[strlen(num)-1]=='\n') num[strlen(num)-1]='\0';
for(int i=0;i<n;i++){
scanf("%d ",&n1);
if(n1==1){
char num1[1000];
fgets(num1,sizeof(num1),stdin);
if(num1[strlen(num1)-1]=='\n') num1[strlen(num1)-1]='\0';
strcat(num,num1);
for(int i=0;i<strlen(num);i++){
printf("%c",num[i]);
}
printf("\n");
}
if(n1==2){
int a,b;
char q2;
scanf("%d %d%c",&a,&b,&q2);
char num1[1000];
strcpy(num1,&num[a]);
num1[a]='\0';
for(int i=0;i<strlen(num1);i++){
printf("%c",num1[i]);
}
printf("\n");
strcpy(num,num1);
}
if(n1==3){
int a;
scanf("%d ",&a);
char num1[1000],num2[1000];
fgets(num2,sizeof(num2),stdin);
if(num2[strlen(num2)-1]=='\n') num2[strlen(num2)-1]='\0';
strcpy(num1,&num[a]);
num[a]='\0';
strcat(&num[a],num2);
strcat(num,num1);
for(int i=0;i<strlen(num);i++){
printf("%c",num[i]);
}
printf("\n");
}
if(n1==4){
char num1[1000];
fgets(num1,sizeof(num1),stdin);
if(num1[strlen(num1)-1]=='\n') num1[strlen(num1)-1]='\0';
if(strstr(num,num1)==NULL) printf("-1");
else{
char*qs=strstr(num,num1);
printf("%d",qs-num);
}
printf("\n");
}
}
return 0;
}
by Lsm2013 @ 2024-12-09 21:26:16
把前面两行改成
#include<bits/stdc++.h>
using namespace std;
by Lsm2013 @ 2024-12-09 21:35:59
好像有点古怪……