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 = (n * m) / 2;
- float sum = 0, kolku = 0;
- for(int l = 0; l < k; l++) {
- int x;
- scanf("%d", &x);
- int ok = 0;
- for(int i = 0; i < n; i++) {
- for(int j = 0; j < m; j++) {
- if(mat[i][j] == x) {
- sum += mat[i][j];
- kolku++;
- mat[i][j] = 0;
- ok = 1;
- break;
- }
- }
- if(ok == 1) {
- break;
- }
- }
- }
- printf("%f\n", sum / kolku);
- for(int i = 0; i < n; i++) {
- for(int j = 0; j < m; j++) {
- printf("%d ", mat[i][j]);
- }
- printf("\n");
- }
- }
- /*
- 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