Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <ctype.h>
- #include <math.h>
- int main(int argc, char * argv[]) {
- int n, m;
- scanf("%d%d", &n, &m);
- int mat[n][m];
- for(int i = 0; i < n; i++) {
- for(int j = 0; j < m; j++) {
- scanf("%d", &mat[i][j]);
- }
- }
- int k;
- scanf("%d", &k);
- float sum = 0.0, kolku = 0;
- for(int i = 0; i < k; i++) {
- int a, b;
- scanf("%d%d", &a, &b);
- if(a >= 0 && a < n && b >= 0 && b < m) {
- sum += mat[a][b];
- kolku++;
- }
- }
- printf("%f\n", sum / kolku);
- }
- /*
- 5 4
- 1 2 5 0
- 7 2 3 1
- 12 0 5 4
- 6 1 0 1
- 2 3 4 5
- 4
- 1 2
- 0 4
- 5 1
- 2 2
- **/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement