Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main()
- {
- int a, b, s, d,e, f, i, h,l, k;
- cin >> a >> b;
- k = a;
- i = 0;
- s = 0;
- d = 0;
- f = 0;
- for (k = a; k <= b; k++)
- {
- h = k;
- l = k;
- do
- {
- h =h / 10;
- i++;
- } while (h != 0);
- for (d = 1; d <= i; d++)
- {
- f = l % 10;
- l = l / 10;
- s = s + pow(f, i);
- }
- if (s == k)
- {
- e = 1;
- cout << k;
- }
- }
- if (e != 1)
- cout << "-1";
- cin.get();
- cin.get();
- return(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment