文章

60

粉丝

66

获赞

60

访问

4.3k

头像
水仙花数 题解:
P1034 中南大学机试题
发布于2024年4月25日 23:31
阅读数 58

#include <bits/stdc++.h>
using namespace std;

int n, m;

bool cheak(int x)
{
	int a = x / 100;
	int b = (x / 10) % 10;
	int c = x % 10;
	
	return a * a * a + b * b * b + c * c * c == x;
}

int main()
{
	
	while(cin >> n >> m, n, m)
	{
		bool t = true;
		for(int i = n; i <= m; i ++)
			if(cheak(i)) t = false, cout << i << " ";
			
		if(t) cout << "no";
		cout << endl;
	}
	
    return 0;
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发