本地测试都对但是只有20分
查看原帖
本地测试都对但是只有20分
1116212
Swan416ya楼主2023/11/3 17:10
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
    int move,n,left,right,i;
    char *p;
    char s[200],input[200];
    scanf("%d\n",&n);
    gets(s);
    for(int count=0; count<n; count++)
    {
        scanf("%d ",&move);
        switch(move)
        {
        case 1:
            gets(input);
            strcat(s,input);
            for(int hh=0; hh<strlen(s); hh++)
                printf("%c",s[hh]);
            printf("\n");
            break;
        case 2:
            scanf("%d%d",&left,&right);
            i=0;
            for(int hh=left; hh<=left+right; hh++,i++)
            {
                printf("%c",s[hh]);
                input[i]=s[hh];
            }
            input[i]=0;
            for(int hh=0; hh<=i; hh++)
                s[hh]=input[hh];
            printf("\n");
            break;
        case 3:
            scanf("%d ",&left);
            gets(input);
            for(int j=strlen(s)-1; j>=left; j--)
                s[j+strlen(input)]=s[j];
            i=0;
            for(int j=left; j<left+strlen(input); j++,i++)
                s[j]=input[i];
            for(int hh=0; hh<strlen(s); hh++)
                printf("%c",s[hh]);
            printf("\n");
            break;
        case 4:
            gets(input);
            p=strstr(s,input);
            if(p==NULL)
                printf("-1");
            else
                printf("%d",p-s);
            printf("\n");
            break;
        }
    }
    return 0;
}

为啥啊求大佬看看啊ww

2023/11/3 17:10
加载中...