社区讨论

为什么测试数据对了,但是全wa,而且下载第一个测试点数据也是对的

P5734【深基6.例6】文字处理软件参与者 2已保存回复 6

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
6 条
当前快照
1 份
快照标识符
@m6taoe5p
此快照首次捕获于
2025/02/06 20:09
去年
此快照最后确认于
2025/11/04 09:52
4 个月前
查看原帖
CPP
#include<bits/stdc++.h>
#include <numeric>
using namespace std;

bool isPrame(int x)
{
    if(x<2) return false;
    for(int i=2;i<x/i+1;i++){
        if(x%i==0) return false;
    }
    return true;
}

int main()
{
    string sh;int n,x;string ch[102];int count=0;
    cin>>n>>sh;
    cin.ignore();
    for(int i=0;i<n;i++){
        getline(cin,ch[i]);
    }
    
    for(int i=0;i<n;i++){
        if(ch[i][0]=='1'){
            istringstream iss(ch[i]);string temp1;
            iss>>x>>temp1;
            sh+=temp1;
            cout<<sh<<endl;
        }else if(ch[i][0]=='2'){
            int a,b;istringstream iss(ch[i]);
            iss>>x>>a>>b;
            sh=sh.substr(a,b);
            cout<<sh<<endl;
        }else if(ch[i][0]=='3'){
            string temp2;
            istringstream iss(ch[i]);
            iss>>x>>x>>temp2;
            sh=sh.insert(x,temp2);
            cout<<sh<<endl;
        }else if(ch[i][0]=='4'){
            string temp3;
            istringstream iss(ch[i]);
            iss>>x>>temp3;
            size_t pos=sh.find(temp3);
            if(pos!=string::npos) cout<<pos<<endl;
            else cout<<"-1"<<endl;
        }
        
    }
    return 0;

}

回复

6 条回复,欢迎继续交流。

正在加载回复...