Advertisement
sellmmaahh

z13

Mar 2nd, 2015
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. int main ()
  5. {
  6.     std::cout<<"Unesite dva cijela broja: ";
  7.     int a,b, s(1);
  8.     bool t (true);
  9.     std::cin>>a>>b;
  10.     a+=1;
  11.     for (a; a<=b-1; a++)
  12.     {
  13.         for(int i=2; i<=a-1; i++)
  14.             if((a%i)==0) s+=i;
  15.         if (s==a)
  16.         {
  17.             std::cout<<a<<"  ";
  18.             t=false;
  19.         }
  20.         s=1;
  21. }
  22. if (t) std::cout<<"Nema savrsenih brojeva.";
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement