社区讨论

40分求助

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

讨论操作

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

当前回复
4 条
当前快照
1 份
快照标识符
@lywdvnuo
此快照首次捕获于
2024/07/22 10:44
2 年前
此快照最后确认于
2024/07/22 11:32
2 年前
查看原帖
CPP
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a;
    cin>>a; 
	string b;
    cin>>b;
    for(int i=1;i<=a;i++)
    {
        int c;
        cin>>c;
        if(c==1)
        {
            string d;
            cin>>d;
            b=b+d;
            cout<<b<<endl;
        }
        if(c==2)
        {
            int d,e;
            cin>>d>>e;
            b=b.substr(d,d+e);
            cout<<b<<endl;
        }
        if(c==3)
        {
            int d;
            string e;
            cin>>d>>e;
            b=b.insert(a-1,e);
            cout<<b<<endl;
        }
        if(c==4)
        {
            string d;
            cin>>d;
            if(b.find(d)<100)  
			cout<<b.find(d)<<endl;
			else
			cout<<-1<<endl;
        }
    }
    return 0;
}

回复

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

正在加载回复...