Advertisement
LukaszPanko

Zadanie 27

Mar 29th, 2020
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.76 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void PRZEDZIAL_LPIERWSZE(int l1, int l2)
  6. {
  7.     l1++;
  8.     for(;l1<=l2;l1++){
  9.         if(l1<2||l1==1)
  10.         {
  11.             cout<<2<<" ";
  12.  
  13.         }
  14.         else if(l1==2)
  15.         {
  16.             cout<<3<<" ";
  17.  
  18.         }
  19.         else if(l1>3&&l1<5)
  20.         {
  21.             cout<<5<<" ";
  22.  
  23.         }
  24.         else if(l1%2!=0&&l1%3!=0&&l1%5!=0)
  25.         {
  26.             cout<<l1<<" ";
  27.  
  28.         }
  29.  
  30.     }
  31. }
  32.  
  33.  
  34.  
  35. int main()
  36. {
  37.     int liczba1;
  38.     int liczba2;
  39.     cout << "Podaj poczatek przedzialu: ";
  40.     cin>>liczba1;
  41.     cout << "Podaj koniec przedzialu: ";
  42.     cin>>liczba2;
  43.     cout<<"Liczby pierwsze znajdujace sie w tym przedziale to: ";
  44.     PRZEDZIAL_LPIERWSZE(liczba1,liczba2);
  45.  
  46.     return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement