给你A和B,求[A,B]区间内有多少个水仙花数
  输入描述:
   两个整数,用空格隔开,保证数字都小于等于1000000,否则返回0
  输出描述:
   一个数字,表示[A,B]区间内的水仙花数个数


分析得分点:

        1、输入以空格隔开的两数字(需要解析,去空格)

        2、数字要小于等于1000000,否则返回0

        3、水仙花数的数字位数不确定


具体实现:

package demo;
/**
 * @Author 小猪上天
 * @Email zhuhuaikuan@gmail.com
 * @Data 2019/11/5  14:51
 * @Version V1.0
 * @description
 */
import java.util.Scanner;
/**
 * 给你A和B,求[A,B]区间内有多少个水仙花数
 * 输入描述:
 *  两个整数,用空格隔开,保证数字都小于等于1000000,否则返回0
 * 输出描述:
 *  一个数字,表示[A,B]区间内的水仙花数个数
 *
 */
public class demo1 {
    public static void main(String[] args) {
        String[] input = new Scanner(System.in).nextLine()
                                    .split(" ");
        int a =  Integer.parseInt(input[0]);
        int b = Integer.parseInt(input[1]);
        if(a>b){      //判断输入两数字大小顺序
            a=a+b;
            b=a-b;
            a=a-b;
        }
//        System.out.println(a);
//        System.out.println(b);
        if(b>1000000){     //数字大于1000000返回0
            System.out.println(0);
            return;
        }
        int count=0;
        for(int number=a;number<=b;number++){
            int temp = number;
            int sum = 0;
            for(int i=0;i<GetLength(number);i++){
                sum += Math.pow(temp % 10, GetLength(number));//次方和相加
                temp = temp / 10;
            }
            if (sum == number) {//判断是否相等
                count++;
            }
        }
        System.out.println(count);
    }
    static int GetLength(int number){   //分析数字的具体位数
        int i = 0;
        while (number / 10 > 0) {
            i++;
            number /= 10;
        }
        return i + 1;
    }
}