main.cpp 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4. #include <algorithm>
  5. using namespace std;
  6. const string space = "5";
  7. bool compare(int a, int b) {
  8. return a < b;
  9. }
  10. int main() {
  11. string str;
  12. vector<int> result;
  13. int val = 0;
  14. while (cin >> str) {
  15. int index = 0;
  16. for (; str.size() > 0;) {
  17. index = str.find(space);
  18. if (index < 0) {
  19. val = atoi(str.substr(0, index).c_str());
  20. result.push_back(val);
  21. break;
  22. }
  23. if (index != 0) {
  24. val = atoi(str.substr(0, index).c_str());
  25. result.push_back(val);
  26. }
  27. str = str.substr(index + 1, str.size());
  28. }
  29. sort(result.begin(), result.end(), compare);
  30. for (int i = 0; i < result.size(); i++) {
  31. cout << result.at(i);
  32. if (i != (result.size() - 1)) {
  33. cout << " ";
  34. }
  35. }
  36. cout << endl;
  37. result.clear();
  38. }
  39. return 0;
  40. }