Advertisement
Guest User

Untitled

a guest
Feb 6th, 2020
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     int n;
  6.     cin >> n;
  7.  
  8.     double topNumber;
  9.     double bottomNumber;
  10.  
  11.     double total=0;
  12.     double max = INT_MIN;
  13.     double min = INT_MAX;
  14.     int sum = 0;
  15.     int maxDiff = 0;
  16.    
  17.     for (int i = 1; i <= n; i++)
  18.     {
  19.         cin >> topNumber;
  20.         cin >> bottomNumber;
  21.  
  22.         total = topNumber + bottomNumber;
  23.         sum = sum + total;
  24.         if (total > max)
  25.         {
  26.             max = total;
  27.         }
  28.  
  29.         if (total < min)
  30.         {
  31.             min = total;
  32.         }
  33.  
  34.     }
  35.     maxDiff = max - min;
  36.     if (sum % n == 0&&sum!=0)
  37.     {
  38.         cout << "Yes, value=" << sum / n << endl;
  39.     }
  40.     else
  41.     {
  42.         cout << "No, maxdiff=" << maxDiff << endl;
  43.     }
  44.  
  45.  
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement