SpaceCreator

Untitled

Nov 26th, 2015
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 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, 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. do
  16. {
  17. h = k / 10;
  18. i++;
  19. } while (h != 0);
  20. for (d = 1; d <= i; d++)
  21. {
  22. f = k / 10;
  23. s = s + pow(f, i);
  24. }
  25. if (s == k)
  26. {
  27. e = 1;
  28. cout << k;
  29. }
  30.  
  31. }
  32. if (e != 1)
  33. cout << "-1";
  34.  
  35. cin.get();
  36. cin.get();
  37. return(0);
  38.  
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment