.。。。把你的计算放到while里边啊
这样写
//水仙花数字
#include<iostream>
using namespace std;
int main()
{
int x = 100;
do
{
int a, b, c;
a = x % 10; //个位
b = x / 10 % 10;//十位
c = x / 100; //百位
if (a * a * a + b * b * b + c * c * c == x)
{
cout << x << endl;
}
x++;
} while (x < 1000); system("pause");
return 0;
}
代码截完整啊。而且水仙花说不需要用循环啊 if就可以了