当前位置:   article > 正文

自除数(力扣题库)_力扣腾讯题库

力扣腾讯题库
 public List<Integer> selfDividingNumbers(int left, int right) {
        List<Integer> list = new ArrayList<>();
        for (int i = left; i <= right; i++) {
            List<Integer> list1 = new ArrayList<>();
            int num =i;
            boolean boo=false;
            while (num>0){
                if (num%10==0){
                   boo=true;
                }
                list1.add(num%10);
                num/=10;
            }
            if (boo){
                continue;
            }
            boolean b=true;
            for (int j = 0; j < list1.size(); j++) {
                    if (i%list1.get(j)==0){
                      continue;
                    }
                b=false;
            }
            if (b){
                list.add(i);
            }
        }
        return list;
    }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/正经夜光杯/article/detail/1017530
推荐阅读
相关标签
  

闽ICP备14008679号