Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void sub(unsigned int n,unsigned int &a, unsigned int &b)
- {
- unsigned int cnt=2;
- for(int i=n;i>=2 && cnt;i--)
- { int x=0;
- for(int j=2;j<i/2;j++)
- {
- if(!(i%j))
- x++;
- }
- if(!x)
- {
- cnt--;
- if(cnt == 1)
- a=i;
- else if(cnt == 0)
- b=i;
- }
- }
- }
- int main()
- {
- unsigned int n,a=0,b=0;
- cin>>n;
- sub(n,a,b);
- cout<<a<<" "<<b;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement