Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int zlozona;
- bool pierwszy(int x)
- {
- if (x==2)
- return false;
- for (int i=2;i*i<=x;i++)
- {
- if (x%i==0)
- {
- return true;
- }
- }
- return false;
- }
- bool przedzial(int a,int b)
- {
- for (int j=a;j<=b;j++)
- {
- if (pierwszy(j)==true)
- {
- zlozona=j;
- return true;
- }
- }
- return false;
- }
- int main()
- {
- int ile,a,b;
- cin >>ile;
- for (int i=0;i<ile;i++)
- {
- cin >>a>>b;
- if(przedzial(a,b)==true)
- cout<<zlozona<<"\n";
- else
- cout<<"NIE\n";
- zlozona=0;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement