废码求调

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

tbf123456 @ 2024-08-07 21:11:12

#include <bits/stdc++.h>
using namespace std;
string a,b;
int q,l,k,j;
int main(){
    cin>>q;
    cin>>a;
    int len=a.length();
    for(int i=0; i<q; i++){
        cin>>l;
        if(l==1){
            cin>>b;
            a+=b;
            cout<<a;
        } 
        if(l==2){
            cin>>k>>j;
            b=a;
            a=" ";
            for(int u=k; u<=j; u++) a+=b[u];
            cout<<a;
        }
        if(l==3){
            cin>>k>>b;
            string h=" ";
            for(int u=0; u<k; u++) h+=a[u];
            h+=b;
            cin>>a;
        }
        if(l==4){       
            cin>>b;
            cout<<(int)a.find(b)<<endl;
        }

    }
    return 0;
}

|