Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- using namespace std;
- int main()
- {
- vector<bool> arr(100 + 1, true);
- arr[0] = false;
- arr[1] = false;
- for (int i = 2; i <= 100; i++)
- {
- if (arr[i])
- {
- for (int j = 2 * i; j <= 100; j += i)
- arr[j] = false;
- }
- }
- vector<int> nums;
- for (int i = 0; i <= 100; i++)
- {
- if (arr[i])
- nums.push_back(i);
- }
- int num = 0, p = 0;
- while (nums[num] <= 50)
- {
- cout << nums[num] << endl;
- string x;
- cin >> x;
- if (x == "yes")
- {
- p++;
- if (nums[num] * nums[num] < 50)
- {
- cout << nums[num] * nums[num] << endl;
- cin >> x;
- if (x == "yes")
- p++;
- }
- }
- num++;
- }
- if (p > 1)
- cout << "composite" << endl;
- else
- cout << "prime" << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement