SHARE
TWEET

Untitled

a guest Apr 24th, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "stdafx.h"
  2. #include "iostream"
  3. #include "math.h"
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     int max_one = 0, max_two = 0, min_one = 0, min_two = 0, a = 0, N = 0;
  10.    
  11.     cin >> N;
  12.     if (N >= 2 && N <= 100) {
  13.             cin >> a;
  14.         if (abs(a) <= 1000) {
  15.             max_one = a;
  16.             min_one = a;
  17.         }
  18.  
  19.         cin >> a;
  20.         if (abs(a) <= 1000) {
  21.             max_two = a;
  22.             min_two = a;
  23.         }
  24.  
  25.         for (int i = 0; i < N - 2; i++) {
  26.             cin >> a;
  27.             if (a > max_one && abs(a) <= 1000) {
  28.                 max_one = a;
  29.             }
  30.             else if (a > max_two && abs(a) <= 1000) {
  31.                 max_two = a;
  32.             }
  33.  
  34.             if (a < min_one && abs(a) <= 1000) {
  35.                 min_one = a;
  36.             }
  37.             else if (a < min_two && abs(a) <= 1000) {
  38.                 min_two = a;
  39.             }
  40.         }
  41.    
  42.         if (min_one < 0 && min_two < 0 && min_one * min_two > max_one * max_two) {
  43.             cout << min_two << " " << min_one<< endl;
  44.         }
  45.         else {
  46.             cout << max_two << " " << max_one << endl;
  47.         }
  48.     }
  49.  
  50.    
  51.  
  52.     return 0;
  53. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top