Advertisement
ostapdontstop

Untitled

Dec 7th, 2017
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.03 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int m=5, n=3;
  8.     int a[m][n];
  9.  
  10.     for (int i = 0; i < m; ++i){
  11.         for (int j = 0; j < n; ++j){
  12.             a[i][j] = 4-i-j*2;
  13.             cout<<a[i][j]<<"   ";}
  14.         cout<<endl;
  15.     }
  16.     int min, max;
  17.  
  18.     bool cond_1, cond_2;
  19.     cond_1, cond_2 = 0;
  20.  
  21.     for (int i = 0, j, _min; i < m; ++i){
  22.         _min = cond_1 ? min:a[i][0];
  23.         for (j = 0 ; j < n; ++j){
  24.             if (a[i][j]%2 != 0) break;
  25.             _min = a[i][j] < _min ? a[i][j]:_min;
  26.         }
  27.         if (j==n) {
  28.             min = _min;
  29.             cond_1 = true;
  30.             }
  31. }
  32.     if (cond_1) cout << "min="<<min<<endl;
  33.     else cout << "netu_min"<<endl;
  34.  
  35.     for (int j = 0, chet = 0, nech = 0, _max ; j < n; ++j){
  36.         _max = cond_2 ? max:a[0][j];
  37.         for (int i = 0 ; i < m; ++i){
  38.             _max = a[i][j] > _max ? a[i][j]:_max;
  39.             if (a[i][j]%2 == 0) chet++;
  40.             else nech++;
  41.         }
  42.         if (chet>nech) {
  43.             cond_2 = true;
  44.             max = _max;
  45.         }
  46.     }
  47.     if (cond_2) cout << "max=" <<max<<endl;
  48.     else cout << "netu_max"<<endl;
  49.  
  50.     if (cond_1 && cond_2) cout<<"z="<<min + max<<endl;
  51.     else cout<<"netu_z"<<endl;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement