Advertisement
Guest User

Untitled

a guest
Jan 24th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.78 KB | None | 0 0
  1. #include<iostream>
  2. #include<string>
  3. #include<stdio.h>
  4. #include<vector>
  5. #include<algorithm>
  6. #include<cmath>
  7. using namespace std;
  8.  
  9. void kwo()
  10. {
  11.     char ch;
  12.     cin >> ch;
  13.  
  14. }
  15.  
  16.  
  17.  
  18. int main()
  19. {
  20.     int range = 0;
  21.     cout << "Type range: ";
  22.     cin >> range;
  23.     int variable = 4;
  24.  
  25.     //declaration of vector
  26.     vector <int> v(2);
  27.     v[0] = 2;
  28.     v[1] = 3;
  29.     ////////////
  30.     int pomoc = 0;
  31.  
  32.     while (variable <= range)
  33.     {
  34.  
  35.         for (int i = 0; i < v.size(); i++)
  36.         {
  37.            
  38.             if (variable %v[i] != 0)
  39.             {
  40.                 pomoc++;
  41.             }
  42.  
  43.         }
  44.        
  45.         if (pomoc == v.size())
  46.         {
  47.             v.push_back(variable);
  48.         }
  49.  
  50.         pomoc = 0;
  51.  
  52.         variable++;
  53.     }
  54.  
  55.  
  56.  
  57.  
  58.     for (int i = 0; i < v.size(); i++)
  59.     {
  60.         cout << "Liczba pierwsza: " << v[i] << "\n";
  61.     }
  62.  
  63.  
  64.  
  65.  
  66.  
  67.     kwo();
  68.  
  69.     system("pause");
  70.  
  71.     return 0;
  72.  
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement