我用DEV C++ 跑出來的答案應該都對...
但是測資就是不給過
麻煩高手解答
#include <iostream>
using namespace std;
int fon (int a,int x);
int main()
{
int m;
int n;
int x[100];
int temp;
int exp;
int sum;
int s;
int f;
int count;
while (cin >> m >> n) {
count = 0;
s = n - m + 1;
for (int k = 0; k < s; k++) {
temp = m;
exp = 0;
for (int i = 0; i<100; i++) {
x[i] = m % 10;
m = m / 10;
exp++;
if (m == 0) {
break;
}
}
m = temp;
sum = 0;
for (int j = 0; j < exp; j++) {
f = fon(exp, x[j]);
sum = sum + f;
}
if (sum == m) {
cout << m << endl;
count++;
}
m++;
}
if (count == 0)
cout << "none" << endl;
}
return 0;
}
int fon (int a,int x)
{
int total = 1;
for (int i = 0; i < a; i++)
total = total * x;
return total;
}