SHARE
TWEET

Untitled

a guest Sep 17th, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <fstream>
  3. #include <cmath>
  4.  
  5. using namespace std;
  6.  
  7. bool isPierwsza(int a) {
  8.     if(a<2)
  9.         return false;
  10.        
  11.     for(int i=2;i*i<=a;i++)
  12.         if(a%i==0)
  13.             return false;
  14.  
  15.     return true;
  16. }
  17.  
  18. int main() {
  19.     ofstream zrodlo_zapis("liczby.txt");
  20.     ifstream zrodlo("liczby.txt");
  21.     ofstream wynik("zad_5.txt");
  22.  
  23.     for (int i = 0; i < 999999; i++)
  24.     {
  25.         zrodlo_zapis<<i<<endl;
  26.     }
  27.        
  28.     zrodlo_zapis.close();
  29.  
  30.     while(!zrodlo.eof()) {
  31.         int liczba;
  32.         zrodlo>>liczba;
  33.         if(isPierwsza(sqrt(liczba))) {
  34.             wynik<<liczba<<endl;
  35.         }
  36.     }
  37. }
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