文章
84
粉丝
408
获赞
33
访问
872.7k
#include<iostream>
using namespace std;
bool fun(int num)
{
int a = num/100;
int b = (num%100)/10;
int c = num%10;
int tmp = a*a*a + b*b*b + c*c*c;
if (tmp == num)
return true;
else
return false;
}
int main()
{
int m, n;
while (1) {
cin >> m >> n;
if (m == 0 && n == 0)
break;
if (m > n || m < 100 || m > 999 || n < 100 || n > 999)
exit(1);//不规范输入
bool flag = false;//是否存在水仙花数
for (int i = m; i <= n; i++) {
if (fun(i)) {
cout << i << " ";
flag = true;
}
}
if (!flag)
cout << "no";
cout << endl;
}
return 0;
}
登录后发布评论
暂无评论,来抢沙发