fork download
  1. #include <iostream>
  2. #include <iterator>
  3. #include <set>
  4. using namespace std;
  5.  
  6. int main() {
  7. int in_number;
  8. enum{ end_of_input_value = 0, which_from_end = 3 };
  9. set<int> numbers;
  10.  
  11. while((cin>>in_number) && in_number != end_of_input_value)
  12. numbers.insert(in_number);
  13.  
  14. auto it = numbers.cend();
  15. advance(it, -which_from_end);
  16.  
  17. cout << *it;
  18. return 0;
  19. }
Success #stdin #stdout 0s 3476KB
stdin
1337 7 666 123 321 -51 0
stdout
321