Advertisement
RuslanMag

kr

Dec 17th, 2019
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     int n = 7;
  7.     int m = 8;
  8.     const int N = 100;
  9.     int s[N][N];
  10.  
  11.     bool is = true;
  12.  
  13.     for (int i = 0; i < n; i++)
  14.     {
  15.         for (int j = 0; j < m; j++)
  16.         {
  17.             s[i][j] = rand() % 10;
  18.         }
  19.     }
  20.  
  21.     for (int i = 0; i < n; i++)
  22.     {
  23.         for (int j = 0; j < m; j++)
  24.         {
  25.             for (int x = 2; x < sqrt(s[i][j]); x++) {
  26.                 if (s[i][j] % x == 0) {
  27.                     is = false;
  28.                     break;
  29.                 }
  30.             }
  31.         }
  32.     }
  33.  
  34.     if (is)
  35.     {
  36.         cout << "true" << endl;
  37.     }
  38.     else
  39.     {
  40.         cout << "false" << endl;
  41.     }
  42.  
  43.     for (int i = 0; i < n; i++)
  44.     {
  45.         for (int j = 0; j < m; j++)
  46.         {
  47.             cout << s[i][j] << " ";
  48.         }
  49.         cout << endl;
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement