水仙花数:每位数字的三次方相加等于该数字,需求得三位数的水仙花数
#include<iostream>
using namespace std;
int main() {//主函数返回值为整型
//dowhile求水仙花数
int num = 100;
int a = 0;
int b = 0;
int c = 0;
do {
a = num % 10;
b = num / 10 % 10;
c = num / 100;
if (a * a * a + b * b * b + c * c * c == num)
{
cout << num << endl;
}
num=num+1;
}
while(num<1000)
system("pause");//暂停系统命令
return 0;//退出程序
}