Java seek 100~999 The number of daffodils :
package mqday02_2019;
public class Demo14 {
public static void main(String[] args) {
// TODO Auto-generated method stub
// Output 100~999 The number of daffodils
int a=0;
System.out.println("100~999 The number of daffodils is :");
for(int i=100;i<=999;i++) {
int bw=i/100; // Find the hundred digit number
int sw=i%100/10; // Find the ten digit number
int gw=i%10; // Find a bit value
int sum=bw*bw*bw+sw*sw*sw+gw*gw*gw; // The sum of the cubes of the digits
if(sum==i){ // The sum of cubes is equal to the number itself , The number of daffodils
a++;
System.out.println(i);
}
}
System.out.println("100~999 Total number of daffodils :"+a);
}
}