SHARE
TWEET

Untitled

a guest Oct 16th, 2019 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. int main(){
  4.     int n = 1;
  5.     while(!n%2 || n<3){
  6.         std::cin >> n;
  7.     }
  8.     int* primes = new int[n];
  9.     int ele = 0;
  10.     for(int i=2; i<=n; i++){
  11.         bool isPrime = true;
  12.         for(int j=2; j<i; j++){
  13.             if(i%j == 0){
  14.                 isPrime = false;
  15.                 break;
  16.             }
  17.         }
  18.         if(isPrime){
  19.             primes[ele] = i;
  20.             ele++;
  21.         }
  22.     }
  23.     for(int i=4; i<=n; i+=2){
  24.         std::cout << "Liczba: " << i << "\n";
  25.         for(int z=0; z<ele; z++){
  26.             for(int x=0; x<ele; x++){
  27.                 if(primes[z]+primes[x] == i){
  28.                     std::cout << "[" << primes[z] << ", " << primes[x] << "]\n";
  29.                 }
  30.             }
  31.         }
  32.     }
  33.     delete primes;
  34. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top