JAVA practice3
daffodils
编写Java 程序打印 “水仙花” 数
(它的个、十、百位数字的立方的和等于该数本身,如:153=13+53+3^3)
package daffodils;
public class daffodils_
{
public static void main(String[] args)
{
int i;//水仙花的百位数变量
int a;//百
int b;//十
int c;//个System.out.println("水仙花的花数为:");
for(i=100;i<=999;i++)
{
a=i/100;
b=i%100/10;
c=i%10;
//System.out.print(a);
//System.out.print(b);
//System.out.print(c);
if(i==a*a*a+b*b*b+c*c*c)
System.out.println(i);
}
}
}