import java.util.Scanner;
public class test1 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入一个三位数");
int number = sc.nextInt();
int a = number % 10;
int b = number / 10 % 10;
int c = number / 100 % 10;
if (a * a * a + b * b * b + c * c * c == number) {
System.out.println("这个数是水仙花数!");
}
else {
System.out.println("这个数不是水仙花数!");
}
}
}
用Java实现对水仙花数的输入和判断
最新推荐文章于 2024-04-28 20:29:16 发布