Advertisement
cska1312

03. Largest 3

May 11th, 2023
593
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include <iostream>
  2. #include <climits>
  3. #include <set>
  4. #include <string>
  5. #include <vector>
  6. #include <sstream>
  7. #include <list>
  8. #include <algorithm>
  9. using namespace std;
  10.  
  11. int main()
  12. {
  13.   string buffer;
  14.   getline(cin, buffer);
  15.  
  16.   istringstream istr(buffer);
  17.  
  18.   double dbl;
  19.   set<double, greater<double> > occurrences;
  20.   while(istr >> dbl)
  21.     occurrences.insert(dbl);
  22.  
  23.   size_t count = 3;
  24.   for(auto item : occurrences)
  25.     {
  26.       cout << item << ' ';
  27.       count--;
  28.       if(!count)
  29.         break;
  30.     }
  31.   cout << endl;
  32.  
  33.   return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement