Advertisement
Spocoman

05. Sort Numbers

Jan 26th, 2024
794
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. #include <iostream>
  2. #include <sstream>
  3. #include <string>
  4. #include <set>
  5.  
  6. using namespace std;
  7.  
  8. int main() {
  9.     string line;
  10.     getline(cin, line);
  11.  
  12.     istringstream ss(line);
  13.  
  14.     set<int> numbers;
  15.  
  16.     int number;
  17.  
  18.     while (ss >> number) {
  19.         numbers.insert(number);
  20.     }
  21.  
  22.     while (!numbers.empty()) {
  23.         cout << *numbers.begin();
  24.         numbers.erase(numbers.begin());
  25.         if (!numbers.empty()) {
  26.             cout << " <= ";
  27.         }
  28.     }
  29.  
  30.     cout << endl;
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement