Advertisement
Josif_tepe

Untitled

Dec 24th, 2020
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.91 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <ctype.h>
  5.  
  6. int main()
  7. {
  8.     int n,m;
  9.     int maksimalen_broj=-1000000;
  10.     int mi;
  11.     int mj;
  12.     scanf("%d%d",&n,&m);
  13.     int mat[n][m];
  14.     for(int i=0;i<n;i++)
  15.         for(int j=0;j<m;j++){
  16.             scanf("%d", &mat[i][j]);
  17.             if(maksimalen_broj<mat[i][j]){
  18.                 maksimalen_broj=mat[i][j];
  19.                 mi=i;
  20.                 mj=j;
  21.             }
  22.                
  23.         }
  24.         if(mi -1>=0 && mj -1>=0){ // gore i levo
  25.            printf("%d ",mat[mi-1][mj-1]);
  26.          }
  27.          if(mi-1>=0 && mj+1<m){ // gore i desno
  28.             printf("%d ",mat[mi-1][mj+1]);
  29.          }
  30.          if(mi+1<n && mj-1>=0){ // dole i levo
  31.             printf("%d ",mat[mi+1][mj-1]);
  32.          }
  33.          if(mi+1<n && mj+1<m){ // dole i desno
  34.             printf("%d ",mat[mi+1][mj+1]);
  35.          }
  36.          return 0;
  37. }
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement