Advertisement
Spocoman

03. Largest 3

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