求助,水仙花数为何这样码没有输出结果?
  • 板块学术版
  • 楼主Dream_liu
  • 当前回复7
  • 已保存回复7
  • 发布时间2023/8/11 12:18
  • 上次更新2023/11/3 04:31:13
查看原帖
求助,水仙花数为何这样码没有输出结果?
1047750
Dream_liu楼主2023/8/11 12:18

求大佬解答!

#include<iostream>
using namespace std;
int main()//求三位数中的所有水仙花数
{
	int a = 100;
	int ge, shi, bai;
	ge = a % 10;
	shi = a / 10 % 10;
	bai = a / 100 % 10;
	do
	{
		if (ge*ge*ge + shi*shi*shi + bai*bai*bai == a)
		{
			cout << a << endl;
		}
		a++;
	} while (a < 1000);
	system("pause");
	return 0;
}
2023/8/11 12:18
加载中...