HDU 1106 Sort (sort + process String)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.