Advertisement
strg_guy

Untitled

Jun 20th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.78 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     vector<bool> arr(100 + 1, true);
  9.     arr[0] = false;
  10.     arr[1] = false;
  11.     for (int i = 2; i <= 100; i++)
  12.     {
  13.         if (arr[i])
  14.         {
  15.             for (int j = 2 * i; j <= 100; j += i)
  16.                 arr[j] = false;
  17.         }
  18.     }
  19.    
  20.     vector<int> nums;
  21.     for (int i = 0; i <= 100; i++)
  22.     {
  23.         if (arr[i])
  24.             nums.push_back(i);
  25.     }
  26.  
  27.     int num = 0, p = 0;
  28.     while (nums[num] <= 50)
  29.     {
  30.         cout << nums[num] << endl;
  31.         string x;
  32.         cin >> x;
  33.         if (x == "yes")
  34.         {
  35.             p++;
  36.             if (nums[num] * nums[num] < 50)
  37.             {
  38.                 cout << nums[num] * nums[num] << endl;
  39.                 cin >> x;
  40.                 if (x == "yes")
  41.                     p++;
  42.             }
  43.         }
  44.         num++;
  45.     }
  46.  
  47.     if (p > 1)
  48.         cout << "composite" << endl;
  49.     else
  50.         cout << "prime" << endl;
  51.     return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement