最小字符串 题解:
#include<iostream>
#include<string>
using namespace std;
int main()
{
string s;
cin >> s;
string ans = "";
int n = s.size();
for (int i = 0; i < n ; i++) {
int j = i;
while (s[++j] == s[i]);
if (s[i] < s[j])ans += s[i];
ans += s[i];
}
cout << ans;
}
登录后发布评论
暂无评论,来抢沙发