Run ID:118114

提交时间:2025-04-23 21:23:49

#include <iostream> #include <string> using namespace std; int main() { string s; string s1 = "er"; string s2 = "ly"; string s3 = "ing"; cin >> s; if(s.size() == 1) { cout << s << endl; return 0; } int x = s.rfind(s1); int y = s.rfind(s2); int z = s.rfind(s3); if(x + 2 == s.size()) { for(int i = 0; i < x; ++i) cout << s[i]; } else if(y + 2 == s.size()) { for(int i = 0; i < y; ++i) cout << s[i]; } else if(z + 3 == s.size()) { for(int i = 0; i < z; ++i) cout << s[i]; } else { cout << s << endl; } return 0; }