SpaceCreator

Untitled

Nov 26th, 2015
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4. int main()
  5. {
  6. int a, b, s, d,e, f, i, h,l, k;
  7. cin >> a >> b;
  8. k = a;
  9. i = 0;
  10. s = 0;
  11. d = 0;
  12. f = 0;
  13. for (k = a; k <= b; k++)
  14. {
  15. h = k;
  16. l = k;
  17. do
  18. {
  19. h =h / 10;
  20. i++;
  21. } while (h != 0);
  22. for (d = 1; d <= i; d++)
  23. {
  24. f = l % 10;
  25. l = l / 10;
  26. s = s + pow(f, i);
  27. }
  28. if (s == k)
  29. {
  30. e = 1;
  31. cout << k;
  32. }
  33.  
  34. }
  35. if (e != 1)
  36. cout << "-1";
  37.  
  38. cin.get();
  39. cin.get();
  40. return(0);
  41.  
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment