#55203: c++正解跟思路 (想學再點)


yp11451032@yphs.tp.edu.tw (711-23吳嘉恩)


#include<bits/stdc++.h>
using namespace std;
int main(){
    string a,b,left,right;
    int p;
    cin>>a>>b;
    p=a.find(b);
    //在a中搜尋子字串b,並將找到的第一個起始位置給p
    left=a.substr(0,p);
    //拿b左側的字串:從0開始,長度為p的子字串
    right=a.substr(p+b.size());
    //拿b右側的字串:從b後面的第一個位置開始擷取到結尾
    reverse(right.begin(),right.end());//反轉
    reverse(left.begin(),left.end());
    cout<<right<<b<<left<<'\n';
}