fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n,min,max,x;
  6. cin >> n;
  7. if (n<2) cout << "Ooops!";
  8. else {
  9. cin >> min;
  10. max=min;
  11. for (int i=0; i<n-1; i++) {
  12. cin >> x;
  13. if (x<min) min=x;
  14. if (x>max) max=x;
  15. }
  16. cout << min << " " << max;
  17. }
  18. return 0;
  19. }
Success #stdin #stdout 0s 15232KB
stdin
8
6 12 9 5 8 15 7 10
stdout
5 15