提交 90363a74 编写于 作者: W wumingfang

feat:水仙花数

上级 54e8de14
import java.util.Scanner;
/**
* @description:
* @author: wmf
* @create: 2022-10-13 14:21
**/
public class TestMain {
public static void main(String[] args) {
Scanner myscanner = new Scanner(System.in);
System.out.println("请输入数字"); // 提示用户输入
while(true){
int number = myscanner.nextInt(); // 接收用户输入
int number1 = number / 100; // 取百位
int number2 = number % 100 / 10; // 取十位
int number3 = number % 10; // 取个位
if (number1 * number1 * number1 +
number2 * number2 * number2 +
number3 * number3 * number3 == number) {
System.out.println(number + "是水仙花数");
} else {
System.out.println(number + "不是水仙花数");
}
}
}
}
# 水仙花数
水仙花数,一个三位数,其各位数字得立方和等于本身,
例如 153 = 1*1*1 + 5*5*5 + 3*3*3。
输入一个数字,判断是否是水仙花数。
## 输入描述
输入一个数字。
## 输出描述
是否是水仙花数。
## 输入样例
153
## 输出样例
## 提示
153
\ No newline at end of file
408
\ No newline at end of file
123
\ No newline at end of file
234
\ No newline at end of file
999
\ No newline at end of file
879
\ No newline at end of file
666
\ No newline at end of file
587
\ No newline at end of file
370
\ No newline at end of file
371
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册