请判断一个数是不是水仙花数。其中水仙花数定义各个位数立和等于它本身的三位数。
如果n是水仙花数就输出Yes
否则输出No
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int a=sc.nextInt();
int b =a;
int c=a0/10;
int d=a/100;
int sum = b*b*b+c*c*c+d*d*d;
if(sum==a){
System.out.println("是水仙花数");
}
else{
System.out.println("不是水仙花数");
}
}
转载请注明原文地址: https://ju.6miu.com/read-22234.html