Josif_tepe

Untitled

Aug 20th, 2025
296
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 <stdlib.h>
  3. int main() {
  4.    
  5.     int n, m;
  6.     scanf("%d%d", &n, &m);
  7.  
  8.     int A[n][m];
  9.     for(int i = 0; i < n; i++) {
  10.         for(int j = 0; j < m; j++) {
  11.             scanf("%d", &A[i][j]);
  12.         }
  13.     }
  14.    
  15.     int podredena_A[n][m];
  16.     for(int i = 0; i < n; i++) {
  17.         int cj = 0;
  18.        
  19.         for(int j = 0; j < m; j++) {
  20.             if(A[i][j] % 2 == 0) {
  21.                 podredena_A[i][cj] = A[i][j];
  22.                 cj++;
  23.             }
  24.         }
  25.        
  26.         for(int j = 0; j < m; j++) {
  27.             if(A[i][j] % 2 == 1) {
  28.                 podredena_A[i][cj] = A[i][j];
  29.                 cj++;
  30.             }
  31.         }
  32.     }
  33.    
  34.     for(int i = 0; i < n; i++) {
  35.         for(int j = 0; j < m; j++) {
  36.             printf("%d ", podredena_A[i][j]);
  37.         }
  38.         printf("\n");
  39.     }
  40.     return 0;
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment