Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #define MAX 500
- int main()
- {
- int n, m;
- scanf("%d%d", &n, &m);
- int mat[MAX][MAX];
- for(int i = 0; i < n; i++) {
- for(int j = 0; j < m; j++) {
- scanf("%d", &mat[i][j]);
- }
- }
- int k = (n * m) / 2;
- int niza[k];
- for(int i = 0; i < k; i++) {
- scanf("%d", &niza[i]);
- }
- int zbir = 0;
- int brojac = 0;
- for(int i = 0; i < k; i++) {
- int flag = 0;
- for(int x = 0; x < n; x++) {
- for(int y = 0; y < m; y++) {
- if(mat[x][y] == niza[i]) {
- zbir += mat[x][y];
- brojac++;
- flag = 1;
- mat[x][y] = 0;
- break;
- }
- }
- if(flag == 1) {
- break;
- }
- }
- }
- printf("%d", zbir / brojac);
- return 0;
- }
- /*
- 5 4
- 1 2 5 0
- 7 2 3 1
- 12 0 5 4
- 6 1 0 1
- 2 3 4 5
- 1 3 -2 5 14 13 7 8 9 11
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement