#include <iostream>
#include <string>
using namespace std;
int main() {
string s1, s2;
cin >> s1 >> s2;
int p = s1.rfind(s2);
if (p != string::npos)
s1.erase(p, s2.size());
cout << s1;
}
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
#include <iostream>
#include <string>
using namespace std;
int main() {
string s1, s2;
cin >> s1 >> s2;
int p = s1.rfind(s2);
if (p != string::npos)
s1.erase(p, s2.size());
cout << s1;
}