功能能实现,但是c++0分,求大佬调谢谢谢谢

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

zhang33 @ 2024-11-08 10:19:16

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

by wwtpp @ 2024-11-08 10:25:28

@zhang33 操作4输出整数之后没有换行


by wwtpp @ 2024-11-08 10:27:55

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

by wwtpp @ 2024-11-08 10:28:41

现在AC了 @zhang33


by wwtpp @ 2024-11-08 10:29:11

string.find()参数是string


by wwtpp @ 2024-11-08 10:33:20

@zhang33 大佬是他


|