Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <windows.h>
- using namespace std;
- bool isSimple(int n)
- {
- if (n == 1)// 1 это не простое число
- return false;
- for (int i = 2; i * i <= n; ++i)
- if (n % i == 0)
- return false;
- return true;
- }
- int main()
- {
- int x;
- cout << "X = ";
- cin >> x;
- int n;
- cout << "N = ";
- cin >> n;
- vector<int> a(n);
- for (int i = 0; i < n; ++i)
- {
- cin >> a[i];
- if (isSimple(a[i]))
- a[i] = x;
- }
- for (int i = 0; i < n; ++i)
- cout << a[i] << ' ';
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement