1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- #include <iostream>
- #include <vector>
- #include <string>
- #include <algorithm>
- using namespace std;
- const string space = "5";
- bool compare(int a, int b) {
- return a < b;
- }
- int main() {
- string str;
- vector<int> result;
- int val = 0;
- while (cin >> str) {
- int index = 0;
- for (; str.size() > 0;) {
- index = str.find(space);
- if (index < 0) {
- val = atoi(str.substr(0, index).c_str());
- result.push_back(val);
- break;
- }
- if (index != 0) {
- val = atoi(str.substr(0, index).c_str());
- result.push_back(val);
- }
- str = str.substr(index + 1, str.size());
- }
- sort(result.begin(), result.end(), compare);
- for (int i = 0; i < result.size(); i++) {
- cout << result.at(i);
- if (i != (result.size() - 1)) {
- cout << " ";
- }
- }
- cout << endl;
- result.clear();
- }
- return 0;
- }
|