fork download
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <vector>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. std::vector<double> balls;
  10.  
  11. double ball;
  12. char const* const prompt = "\nnumber?\n> ";
  13. while (cout << prompt, cin >> ball)
  14. {
  15. balls.push_back(ball);
  16. sort(balls.begin(), balls.end());
  17.  
  18. bool just_another_number = true;
  19.  
  20. const std::size_t size = balls.size();
  21. if (ball == balls.front())
  22. {
  23. if (size == 1 || size > 1 && balls[1] != ball)
  24. {
  25. just_another_number = false;
  26. cout << ball << " is the smallest number yet!\n";
  27. }
  28. }
  29.  
  30. if (ball == balls.back())
  31. {
  32. if (size == 1 || size > 1 && balls[balls.size() - 2] != ball)
  33. {
  34. just_another_number = false;
  35. cout << ball << " is the largest number yet!\n";
  36. }
  37. }
  38.  
  39. if (just_another_number)
  40. cout << '\n' << ball << " is just another number.\n";
  41. }
  42. }
Success #stdin #stdout 0s 3468KB
stdin
10
10
5
2
-1
-1
11
12
12
quit
stdout
number?
> 10 is the smallest number yet!
10 is the largest number yet!

number?
> 
10 is just another number.

number?
> 5 is the smallest number yet!

number?
> 2 is the smallest number yet!

number?
> -1 is the smallest number yet!

number?
> 
-1 is just another number.

number?
> 11 is the largest number yet!

number?
> 12 is the largest number yet!

number?
> 
12 is just another number.

number?
>