Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- int perfect(int x)
- {
- int i,s=0;
- for(i=1;i<=x;i++)
- if(x%i==0)
- s++;
- if(2*x==s)
- return 1;
- else return 0;
- }
- int main()
- {
- ifstream f("perfect.in");
- int n,i=1,max=0,poz;
- while(f>>n)
- {
- if(perfect(n)==1&&max<n)
- {
- max=n;
- poz=i;
- }
- i++;
- }
- if(max==0 )
- cout<<"imposibil";
- else cout<<max<<" "<<poz;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement