Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.85 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdlib.h>
  3. #include <ctime>
  4. using namespace std;
  5.  
  6. int main() {
  7.     srand(time(NULL));
  8.     int a [101];
  9.     for (int i = 0; i <= 100; i++)
  10.         a[i] = i;
  11.        
  12.     int ch = 0;
  13.     for (int i = 2;i<100;i++)
  14.     {
  15.         ch = 0;
  16.         for(int j = 2;j<i;j++)
  17.         {
  18.             if (i%j==0)
  19.             {
  20.                 ch++;
  21.             }
  22.            
  23.         }
  24.         if (ch==0)
  25.         a[i] = 0;
  26.     }
  27.  
  28.     int m = a[rand()%100];
  29.     while (m==0)
  30.         m = a[rand()%100];
  31.        
  32.     int n = a[rand()%100];
  33.     while (n==0)
  34.         n = a[rand()%100];
  35.        
  36.     cout << m << " " << n<< endl;
  37.    
  38.     while (m != n)
  39.     {
  40.         if (m > n)
  41.             m = m - n;
  42.         else
  43.             n = n - m;
  44.     }
  45.     cout << "\nNaibol'shhiy obshiy delitel' = " <<m;
  46.  
  47.     return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement