。。。虽然华为不让我笔试。。不过你的程序好像根本不对吧。。。。 你输入432143214321试试。。。。 #include <iostream> #include <vector> #include <string> #include <algorithm> using namespace std; int main() { string str; while (cin >> str) { int len = str.length(); vector<int>count(10,0); for (int i = 0; i < len; i++) { count[str[i] - '0']++; } for (int i = 0; i < str.length()-1; i++) { if (str[i] <= str[i + 1] && count[str[i] - '0'] > 1) { count[str[i] - '0']--; str.erase(i, 1); i--; } } for (int i = str.length() - 1; i >=0; i--) { if (count[str[i] - '0'] > 1) { count[str[i] - '0']--; str.erase(i, 1); } } cout << str << endl; } return 0; } 这是我的。。。仅供参考。。。
点赞 2

相关推荐

03-24 00:03
门头沟学院 Java
恶龙战士:实习经历写的不行,需要改,不管是改成主业务还是主技术都可以
点赞 评论 收藏
分享
牛客网
牛客企业服务