import java.util.Scanner;
class ShuiXianHuaShu
{
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
System.out.println("请输入一个100-1000间的数字");
int a=sc.nextInt();
if (a>=100 && a<1000)
{
int x=a%10;
int y=a/10%10;
int z=a/100;
if (a==x*x*x+y*y*y+z*z*z)
{
System.out.println(a+"是水仙花数");
}
else
System.out.println(a+"不是水仙花数");
}
else
{
System.out.println("请输入有效的数据");
}
}
} |