Test instructions: slightly.
Analysis: According to the topic, the string is divided, and then the string into decimal, stored up, you can use the array, I use the vector,
Sort it out OK. Note that, to consider more than 5 adjacent to the time, just at first did not consider WA once.
The code is as follows:
#include <iostream> #include <cstdio> #include <algorithm> #include <queue> #include <vector > #include <cstring> #include <map> #include <cctype>using namespace Std;const int maxn = + 5;char S[maxn];int Main () {while (~scanf ("%s", s)) { vector<int> v; int n = strlen (s); int t = 0; bool OK = false; for (int i = 0; i < n; ++i) if (' 5 ' = = S[i] && ok) { v.push_back (t); t = 0; ok = false;} else if (' 5 '! = S[i]) {t = T * ten + s[i]-' 0 '; OK = true; } if (s[n-1]! = ' 5 ') V.push_back (t); Sort (V.begin (), V.end ()); printf ("%d", v[0]); for (int i = 1; i < v.size (); ++i) printf ("%d", V[i]); printf ("\ n"); } return 0;}
HDU 1106 Sort (sort + process String)