Advertisement
Nikita051

Untitled

Oct 26th, 2022
673
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.97 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <time.h>
  3. #include <locale.h>
  4. #include <stdlib.h>
  5.  
  6. int main(){
  7.     int i,j,n,m,test = 0,count = 0,o;
  8.     int b[count];
  9.     printf("N = ");
  10.     scanf("%d",&n);
  11.     printf("M = ");
  12.     scanf("%d",&m);
  13.     int arr[n][m];
  14.     srand(time(NULL));
  15.     for(i = 0;i<n;i++){
  16.         for(j = 0;j<m;j++){
  17.             arr[i][j] = rand() % 100;
  18.             printf("%d  ",arr[i][j]);
  19.         }
  20.         printf("\n");
  21.     }
  22.     for(i = 0;i<n;i++){
  23.         for(j = 0;j<m;j++){
  24.             for(o = 2;o<arr[i][j];o++){
  25.                 if(arr[i][j]%o == 0){
  26.                     printf("%d - %d\n",arr[i][j],o);
  27.                     test = 1;
  28.                     break;
  29.                 } else {
  30.                     test = 0;
  31.                 }
  32.             }
  33.             if(test == 0){
  34.                 count++;
  35.                 b[count-1] = arr[i][j];
  36.             }
  37.         }
  38.     }
  39.     for(i = 0;i<count;i++){
  40.         printf("%d  ",b[i]);
  41.     }
  42. }
  43.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement