PiotrJurek

Zad27

Mar 30th, 2020
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. bool LICZBA_PIERWSZA(int n)
  6. {
  7. if(n>1)
  8. {
  9. for(int i=2; i<n; i++)
  10. {
  11. if(n%i==0)
  12. {
  13. return false;
  14. }
  15. }
  16. return true;
  17. }
  18. else
  19. {
  20. return false;
  21. }
  22. }
  23.  
  24. void PRZEDZIAL_LPIERWSZE(int x1, int x2)
  25. {
  26. bool ok = true;
  27. for(x1; x1<x2; x1++)
  28. {
  29. if(LICZBA_PIERWSZA(x1))
  30. {
  31. cout << x1 << " ";
  32. ok = false;
  33. }
  34. }
  35. if(ok)
  36. {
  37. cout << "Nic do pokazania";
  38. }
  39. cout << endl;
  40. }
  41.  
  42. int main()
  43. {
  44. PRZEDZIAL_LPIERWSZE(1, 14);
  45. PRZEDZIAL_LPIERWSZE(65, 174);
  46. PRZEDZIAL_LPIERWSZE(98, 99);
  47. return 0;
  48. }
Add Comment
Please, Sign In to add comment