本文共 442 字,大约阅读时间需要 1 分钟。
思路:遍历每一位,直接判断即可
代码
class Solution {public: vector selfDividingNumbers(int left, int right) { vector result; for(int x=left;x<=right;x++){ int temp = x; while(temp){ if(temp%10==0||(x%(temp%10)!=0)){ break; } temp = temp / 10; } if(!temp) result.push_back(x); } return result; }};
转载地址:http://hjrai.baihongyu.com/