Advertisement
Josif_tepe

Untitled

Dec 19th, 2022
658
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.86 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main() {
  5.     int red, kolona;
  6.     scanf("%d%d", &red, &kolona);
  7.    
  8.     int mat[red][kolona];
  9.     for(int i = 0; i < red; i++) {
  10.         for(int j = 0; j < kolona; j++) {
  11.             scanf("%d", &mat[i][j]);
  12.         }
  13.     }
  14.    
  15.     for(int i = 0; i < red; i++) {
  16.         int najgolem_broj = mat[i][0];
  17.         for(int j = 0; j < kolona; j++) {
  18.             if(mat[i][j] > najgolem_broj) {
  19.                 najgolem_broj = mat[i][j];
  20.             }
  21.         }
  22.        
  23.         for(int j = 0; j < kolona; j++) {
  24.             if(mat[i][j] != najgolem_broj) {
  25.                 mat[i][j] = 0;
  26.             }
  27.         }
  28.     }
  29.    
  30.     for(int i = 0; i < red; i++) {
  31.         for(int j = 0; j < kolona; j++) {
  32.             printf("%d ", mat[i][j]);
  33.         }
  34.         printf("\n");
  35.     }
  36.  
  37.    
  38.     return 0;
  39. }
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement