Advertisement
Josif_tepe

Untitled

Jan 14th, 2024
921
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.63 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main() {
  4.     int n, m;
  5.     scanf("%d%d", &n, &m);
  6.    
  7.     int mat[n][m];
  8.     for(int i = 0; i < n; i++) {
  9.         for(int j = 0; j < m; j++) {
  10.             scanf("%d", &mat[i][j]);
  11.         }
  12.     }
  13.     int k;
  14.     scanf("%d", &k);
  15.     int sum = 0, brojac = 0;
  16.     for(int i = 0; i < k; i++) {
  17.         int x, y;
  18.         scanf("%d%d", &x, &y);
  19.         if(x >= 0 && x < n && y >= 0 && y < m) {
  20.             sum += mat[x][y];
  21.             brojac++;
  22.         }
  23.     }
  24.     printf("%d\n", sum / brojac);
  25.     return 0;
  26. }
  27. /*
  28. 4 5
  29. 1 2 5 0
  30. 7 2 3 1
  31. 12 0 5 4
  32. 6 1 0 1
  33. 2 3 4 5
  34. 4
  35. 1 2
  36. 0 4
  37. 5 1
  38. 2 2
  39.  
  40. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement