1025: 水仙花数
Description
打印出所有"水仙花数",所谓"水仙花数"是指一个三位数,其各位数字立方和等于该本身。例如:153是一个水仙花数,因为153=13+53+3^3。
153
???
???
???
Input
无
Output
所有的水仙花数,从小的开始。每行一个
#include <iostream>
#include <math.h>
using namespace std;
int main(){
for(int i=101;i<999;i++){
int a=i%10;
int b=i/10%10;
int c=i/100;
if(pow(a,3)+pow(b,3)+pow(c,3)==i){
cout<<i<<endl;
}
}
return 0;
}