Advertisement
Josif_tepe

Untitled

Jun 12th, 2021
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.94 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <ctype.h>
  3. #include <string.h>
  4. #include <math.h>
  5.  
  6.  
  7. int main(int argc, char *argv[]) {
  8.     int n, m;
  9.     scanf("%d%d", &n, &m);
  10.     int matrica[n][m];
  11.     for(int i = 0; i < n; i++) {
  12.         for(int j = 0; j < m; j++) {
  13.             scanf("%d", &matrica[i][j]);
  14.         }
  15.     }
  16.     int redica[n];
  17.     for(int i = 0; i < n; i++) {
  18.         redica[i] = 1;
  19.     }
  20.     int x;
  21.     while(scanf("%d", &x)) {
  22.         for(int i = 0; i < n; i++) {
  23.             for(int j = 0; j < m; j++) {
  24.                 if(matrica[i][j] == x) {
  25.                     redica[i]++;
  26.                 }
  27.             }
  28.         }
  29.     }
  30.     for(int i = 0; i < n; i++) {
  31.         for(int k = 0; k < redica[i]; k++) {
  32.             for(int j = 0; j < m; j++) {
  33.                 printf("%d ", matrica[i][j]);
  34.             }
  35.             printf("\n");
  36.         }
  37.     }
  38.     return 0;
  39. }
  40. /*
  41.  1 0 2 4
  42.  3 3 23 5
  43.  3 5 5 6
  44.  0 3 12 7
  45.  
  46.  
  47.  1 7
  48.  **/
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement