0分求助

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

kkkkcs003 @ 2024-07-18 19:34:07

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

by manong_czk @ 2024-07-18 20:04:24

cin>>d>>a; 输入反了


by kkkkcs003 @ 2024-08-26 20:28:10

@manong_czk 感谢


|