Advertisement
Guest User

Books 2007

a guest
Apr 28th, 2017
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.03 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int n;
  8.     cin>>n;
  9.  
  10.     int a[n+1][n+1];
  11.     for(int i=0;i<n;i++)
  12.         for(int j=0;j<n;j++)
  13.             cin>>a[i][j];
  14.  
  15.     int cnt=0;
  16.     for(int i=0;i<n;i++){
  17.         for(int j=0;j<n;j++){
  18.             if (a [i][j] == 0)
  19.                     continue;
  20.                 bool moze = true;
  21.                 for (int k = 0; k < i; k++)
  22.                     if (a [k][j] >= a [i][j])
  23.                         moze = false;
  24.                 if (moze == true){
  25.                     cnt++;
  26.                     continue;
  27.                 }
  28.  
  29.                 moze = true;
  30.                 for (int k = i + 1; k < n; k++)
  31.                     if (a [k][j] >= a [i][j])
  32.                         moze = false;
  33.                 if (moze == true){
  34.                     cnt++;
  35.                     continue;
  36.                 }
  37.                 moze = true;
  38.                 for (int k = 0; k < j; k++)
  39.                     if (a [i][k] >= a [i][j])
  40.                         moze = false;
  41.                 if (moze == true){
  42.                     cnt++;
  43.                     continue;
  44.                 }
  45.                 moze = true;
  46.                 for (int k = j + 1; k < n; k++)
  47.                     if (a [i][k] >= a [i][j])
  48.                         moze = false;
  49.                 if (moze == true){
  50.                     cnt++;
  51.                     continue;
  52.                 }
  53.         }
  54.     }
  55.     cout<<cnt<<endl;
  56.     return 0;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement