本地win和linux测都是过的,,但是这里是0分。。
查看原帖
本地win和linux测都是过的,,但是这里是0分。。
658123
dlklwdc楼主2022/8/19 22:45

代码如下:

#include<bits/stdc++.h>
#include<string>
using namespace std;
int q;
string str;
int main()
{
    cin>>q;
    int op[q+1];
    string op1[q+1]={},op3[q+1]={},op4[q+1]={};
    int op2a[q+1]={},op2b[q+1]={},op3a[q+1]={};
    getchar();
    getline(cin,str);
    for(int i=1;i<=q;i++){
        cin>>op[i];
        if(op[i]==1){
            getchar();
            getline(cin,op1[i]);
        }
        if(op[i]==2){
            cin>>op2a[i]>>op2b[i];
        }
        if(op[i]==3){
            cin>>op3a[i];
            getchar();
            getline(cin,op3[i]);
        }
        if(op[i]==4){
            getchar();
            cin>>op4[i];
        }
    }
    for(int i=1;i<=q;i++){
        if(op[i]==1){
            str=str+op1[i];
            cout<<str<<endl;
        }
        if(op[i]==2){
            str=str.substr(op2a[i],op2b[i]);
            cout<<str<<endl;
        }
        if(op[i]==3){
            str=str.insert(op3a[i],op3[i]);
            cout<<str<<endl;
        }
        if(op[i]==4){
           int j=str.find(op4[i]);
            cout<<j<<endl;
        }
    }
}

我真的会谢

2022/8/19 22:45
加载中...