大佬求捞捞

P5734 【深基6.例6】文字处理软件

zhangjunlin123 @ 2024-11-28 17:20:11

q = int(input())
s = input()
ls = [list(map(str,input().split())) for i in range(q)]
for x in ls:
    if x[0] == "1":
        s +=x[1]
        print(s)
    elif x[0] == "2":
        a = int(x[1])
        b = int(x[2])
        s = s[a:a+b]
        print(s)
    elif x[0] == "3":
        a = int(x[1])
        s = s[:a]+x[2]+s[a:]
        print(s)
    else:
        print(s.find(x[1]))

by tt12341234 @ 2024-11-29 20:49:00

@zhangjunlin123 如果有帮助,可以给个关注吗

#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int op;
    for(int i=1;i<=n;i++){
        cin>>op;
        if(op==1){
            string x;
            cin>>x;
            s.insert(s.size(),x);
            cout<<s<<endl;
        }else if(op==2){
            int a,b;
            cin>>a>>b;
            s=s.substr(a,b);
            cout<<s<<endl;
        }else if(op==3){
            int a;
            string x;
            cin>>a>>x;
            s.insert(a,x);
            cout<<s<<endl;
        }else{
            string x;
            cin>>x;
            if(s.find(x)==-1){
                cout<<-1;
            } else{
                cout<<s.find(x);
            }
            cout<<endl;
        }
    }
    return 0;
}

求关


by zhangjunlin123 @ 2024-11-29 22:59:39

@tt12341234 大佬会python吗


|