Advertisement
allia

макс и мин работает

Sep 14th, 2020
1,154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.   int a=0, max=-1, min = 34257;
  8.   cin  >> a;
  9.   int arr[a];
  10.   for (int i=0; i<a; i++)
  11.   {
  12.     cin >> arr[i];
  13.     if (arr[i]%2==0 && arr[i]>max)
  14.       max = arr[i];
  15.     if (arr[i]%2!=0 && arr[i]<min)
  16.       min = arr[i];
  17.   }
  18.   if (min == 34257)
  19.   cout << -1 << " " << max;
  20.   else cout << min << " " << max;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement