Advertisement
Josif_tepe

Untitled

Jun 6th, 2024
353
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.87 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.    for(int i = 0; i < n; i++) {
  16.     int x = 1;
  17.     for(int i2 = i + 1; i2 < n; i2++) {
  18.         int ok = 1;
  19.         for(int j = 0; j < m; j++) {
  20.             if(mat[i][j] != mat[i2][j]) {
  21.                 ok = 0;
  22.             }
  23.         }
  24.         if(ok == 1) {
  25.             for(int j = 0; j < m; j++) {
  26.                 mat[i2][j] += x;
  27.             }
  28.             x++;
  29.         }
  30.     }
  31.    }
  32.   for(int i = 0; i < n; i++) {
  33.     for(int j =0 ; j < m; j++) {
  34.         printf("%d ", mat[i][j]);
  35.     }
  36.     printf("\n");
  37.   }
  38. }
  39. /*
  40. 5 4
  41. 1 2 10 0
  42. 7 2 3 1
  43. 1 2 10 0
  44. 7 2 3 1
  45. 1 2 10 0
  46.  
  47.  
  48. **/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement