Advertisement
Josif_tepe

Untitled

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