Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int vstup1, vstup2;
- int i;
- bool kontrola;
- cout << "Zadejte interval:" << endl;
- cin >> vstup1;
- cin >> vstup2;
- if (cin.fail())
- {
- cout << "Nespravny vstup." << endl;
- return 0;
- }
- if (vstup1-vstup2>0)
- {
- cout << "Nespravny vstup." << endl;
- return 0;
- }
- while (vstup1 <= vstup2)
- {
- kontrola = false;
- for(i = 2; i <= vstup1/2; ++i)
- {
- if(vstup1 % i == 0)
- {
- kontrola = true;
- break;
- }
- }
- if (kontrola == 0 && vstup1>1)
- cout << vstup1 << endl;
- ++vstup1;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment