Advertisement
ostapdontstop

Untitled

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