## L1-094 剪切粘贴

题目链接：
https://pintia.cn/problem-sets/994805046380707840/exam/problems/type/7?problemSetProblemId=1649748772841508869

**解题思路：
本题主要就是考察字符串，还是比较简单的，但是需要同时检查前后字符串，不能只检查前面或者后面的，否则会出错**

具体代码如下：
```cpp
#include<iostream>
#include<string>
using namespace std;
int main(){
    string s;
    cin>>s;
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int start,end;
        cin>>start>>end;
        string temp;//剪切板
        temp=s.substr(start-1,end-start+1);
        s.erase(start-1,end-start+1);
        //本题最关键的是需要同时检查前后字符串，不能只看前面，要不然题目给你后面干嘛
        string start_s,end_s;
        cin>>start_s>>end_s;
        string find_s=start_s+end_s;
        if(s.find(find_s)==string::npos){
            s+=temp;
        }
        else{
            //还有要注意的一点就是插入是在索引前面插入的
            int p=s.find(find_s);
            int pos=p+start_s.size();
            s.insert(pos,temp);
        }
    }
    cout<<s<<endl;
    return 0;
}
