水仙花数
水仙花数,它的每个位上的数字的 3次幂之和等于它本身。例如:1^3 + 5^3+ 3^3 = 153。
System.out.println("输入一个3位数");
Scanner scanner = new Scanner(System.in);
int input = scanner.nextInt();
//取个位
int w1 = input % 10 ;
//取十位
int w2 = ( input - w1 ) % 100 / 10;
//取百位
int w3 = (input - w2 * 10 - w1)/100;
if (w1*w1*w1 + w2*w2*w2 + w3*w3*w3 == input)
System.out.println("是水仙花数");
else
System.out.println("不是水仙花数");