Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- std::vector<int> givePrimes(int num){
- std::vector<int> pri;
- for(int i=2; i<=num; i++){
- bool isPrime = true;
- for(int j=2; j<i; j++){
- if(i%j == 0){
- isPrime = false;
- break;
- }
- }
- if(isPrime){
- pri.push_back(i);
- }
- }
- return pri;
- }
- int main(){
- int n = 1;
- while(!n%2 || n<3){
- std::cin >> n;
- }
- std::vector<int> primes = givePrimes(n);
- for(int i=4; i<=n; i+=2){
- std::cout << "Liczba: " << i << "\n";
- for(int z=0; z<primes.size(); z++){
- for(int x=0; x<primes.size(); x++){
- if(primes[z]+primes[x] == i){
- std::cout << "[" << primes[z] << ", " << primes[x] << "]\n";
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement