求助,在本地没问题,但是在全WA
查看原帖
求助,在本地没问题,但是在全WA
800102
q_n_q楼主2022/12/27 19:08
#include <string.h>
#include <math.h>
#include <stdbool.h>
#include <stdio.h>

int main()
{
    int n;
    char a[101],op;
    scanf("%d\n%s",&n,a);
    while(n--)
    {
        fflush(stdin);
        op=getchar();
        getchar();
        if(op=='1')
        {
            char temp[101];
            strcat(a,gets(temp));
            puts(a);
        }
        else if(op=='2')
        {
            int location,len,pivot=0;
            scanf("%d%d",&location,&len);
            while(len--)a[pivot++]=a[location++];
            a[pivot]='\0';
            puts(a);
        }
        else if(op=='3')
        {
            char temp[101],save[101];
            int location;
            scanf("%d%s",&location,save);
            strcpy(temp,a+location);
            a[location]='\0';
            strcat(a,save);
            strcat(a,temp);
            puts(a);
        }
        else{
            char save[101];
            gets(save);
            char* location=strstr(a,save);
            if(location)printf("%d\n",(int)(location-a));
            else printf("-1\n");
        }
    }
    return 0;
}
2022/12/27 19:08
加载中...