Advertisement
Josif_tepe

Untitled

Jun 3rd, 2024
345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.13 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <ctype.h>
  4.  
  5. int main() {
  6.     int n, m;
  7.     scanf("%d%d", &n, &m);
  8.  
  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.     int rezultat = 0 ;
  16.     for(int i = 0; i < n; i++) {
  17.         int ok = 1;
  18.         for(int j = 0; j < m; j++) {
  19.             int broj_na_deliteli = 0;
  20.             for(int k = 1; k <= mat[i][j]; k++) {
  21.                 if(mat[i][j] % k == 0) {
  22.                     broj_na_deliteli++;
  23.                 }
  24.             }
  25.             if(broj_na_deliteli == 2) {
  26.  
  27.             }
  28.             else {
  29.                 ok = 0;
  30.             }
  31.         }
  32.         if(ok == 1) {
  33.             for(int j = 0; j < m; j++) {
  34.                 printf("%d ", mat[i][j]);
  35.             }
  36.             printf("\n");
  37.             rezultat++;
  38.         }
  39.     }
  40.  
  41.     if(rezultat == 0) {
  42.         printf("Ne se ispolnuva uslovot\n");
  43.     }
  44.     else {
  45.         printf("Uslovot go ispolnuvaat %d redici\n", rezultat);
  46.     }
  47.    
  48. }
  49. /*
  50. 4 4
  51. 2 2 2 11
  52. 17 22 13 10
  53. 3 11 2 2
  54. 1134 1120 5566 9900
  55.  
  56. **/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement