#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <map>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <unordered_map>
using namespace std;
/*解题思路:*/
int main() {
string abc;
cin >> abc; //输入字符串abc
string str(abc);
string::iterator it; //迭代器it
for (it = str.begin(); it != str.end(); ++it) {
if ((*it == 'R') && (*(it + 1) == 'E') && (*(it + 2) == 'D')) {
str.erase(it); //删除it处的一个字符(it是个string类型的迭代器)
str.erase(it);
str.erase(it);
}
}
cout << str << endl;
string tmp;
string max = "0";
for (it = str.begin(); it <= str.end(); ++it) {
cout << tmp << endl;
if (it == str.end()) {
break;
}
if ((*it >= '0') && (*it <= '9')) {
tmp = tmp + *it;
} else {
if (tmp.length() > max.length())
max = tmp;
else if (tmp.length() == max.length()) {
if (tmp > max)
max = tmp;
}
tmp.clear();
}
}
if (tmp.length() > max.length())
max = tmp;
else if (tmp.length() == max.length()) {
if (tmp > max)
max = tmp;
}
if (max == "0")
max = -1;
cout << max << endl;
return 0;
}
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。