Blue Bridge Cup java algorithm training ALGO-147 daffodil number
Problem Description:
Print all daffodil numbers between 100 and 999. The so-called daffodil number refers to an integer that satisfies the cube sum of the digits of the digit itself, such as 153=1 3+5 3+3^3.
Sample input
An input sample that meets the requirements of the question.
Example:
None
Sample output
153
xxx
xxx
Code:
public class Main{
public static void main(String[] args) {
for(int i=100;i<=999;i++){
int a = i/100;//百位
int b = i%100/10;//十位
int c = i%10;//个位
if(i==a*a*a+b*b*b+c*c*c){
System.out.println(i);
}
}
}
}