• Source
    1. #include <iostream>
    2. #include <sstream>
    3. #include <string>
    4. #include <utility>
    5.  
    6. using std::cout;
    7. using std::exchange;
    8. using std::getline;
    9. using std::istream;
    10. using std::istringstream;
    11. using std::string;
    12.  
    13. static void sort(istream& in){
    14. string line;
    15.  
    16. while (getline(in, line)) {
    17. istringstream ss(line);
    18. int number;
    19. auto sep = "";
    20.  
    21. while(ss >> number){
    22. cout << exchange(sep, " ") << number;
    23. }
    24.  
    25. cout << "\n";
    26. }
    27. }
    28.  
    29. static char const* input_data =
    30. R"aw(833 833 835 840 847 850 858 861 866 874
    31. 881 883 892 898 906 915 921 927 936 936
    32. 944 951 953 960 967 975 979 980 989 989
    33. 991 996 997 1001 1001 1001 1001 1002 1006 1011
    34. 1012 1015 1022 1024 1024 1029 1031 1037 1038 1041
    35. )aw";
    36.  
    37. int main() {
    38. istringstream ss(input_data);
    39. sort(ss);
    40. }