Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int n,m;
- cin>>n;
- m=n;
- int x[n][m];
- for(int i = 0;i<n;i++){
- for(int j = 0;j<m;j++){
- cin>>x[i][j];
- }
- }
- bool poseteno[n][m];
- for(int i = 0; i < n; i++) {
- for(int j = 0; j < m; j++) {
- poseteno[i][j] = false;
- }
- }
- int cnt=0;
- for(int i = 0; i < n; i++) {
- for(int j = 0; j < m; j++) {
- bool levo = true;
- for(int k = j - 1; k >= 0; k--) {
- if(x[i][k] >= x[i][j]) {
- levo = false;
- }
- }
- bool desno = true;
- for(int k = j + 1; k < m; k++) {
- if(x[i][k] >= x[i][j]) {
- desno = false;
- }
- }
- bool gore = true;
- for(int k = i - 1; k >= 0; k--) {
- if(x[k][j] >= x[i][j]) {
- gore = false;
- }
- }
- bool dole = true;
- for(int k = i + 1; k < n; k++ ){
- if(x[k][j] >= x[i][j]) {
- dole = false;
- }
- }
- if((levo == true or desno == true or gore == true or dole == true) and x[i][j] != 0) {
- cnt++;
- }
- }
- }
- cout<<cnt<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement