import java.util.Scanner;
public class HomeWork04{ //记得把文件名字改成自己需要的
public static void main(String[] args) {
Scanner sr = new Scanner(System.in);
System.out.println("请输入一个三位数");
int shu = sr.nextInt();
int thi = shu/100; //将百位数赋给thi
int sec = (shu - thi*100)/10; //将十位数赋给sec
int fir = shu % 10; //将个位数赋给fir
if (shu == (thi * thi * thi +sec*sec*sec+fir*fir*fir)) {
System.out.println(shu + "为水仙花数");
}
}
}
java输出水仙花数
于 2024-01-15 23:27:36 首次发布