为啥才40啊,求助

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

QQQcainiao666 @ 2024-09-29 21:36:31

#include<bits/stdc++.h>
using namespace std;

int main(){
    int q;
    string str;
    cin>>q;
    cin>>str;
    while(q--){
        int n;
        cin>>n;
        if(n==1){
            string str2;
            cin>>str2;
            str=str+str2;
            cout<<str<<endl;
        }
        if(n==2){
            int s,e;
            cin>>s>>e;
            str=str.substr(s,e);
            cout<<str<<endl;
        }
        if(n==3){
            int s;
            string tmp;
            cin>>s>>tmp;
            str=str.insert(s,tmp);
            cout<<str<<endl;
        }
        if(n==4){
            string tmp;
            cin>>tmp;
            if(str.find(tmp)){
                cout<<str.find(tmp)<<endl;
            }else{
                cout<<"-1"<<endl;
            }
        }
    }
    return 0;
}

|