1、这道题就是将一个整型数据每位数字剥离出来,看看是不是整形数据的因子。
题目不难,但是出现了个问题???
vector<int> iselfDividingNumbers(int left, int right) {
vector <int> res;
if (left > right) return res;
for (int i=left; i <= right; ++i) {
int remain = 0;
int tmp = i;
while (tmp != 0) {
remain = tmp % 10;
if (remain == 0) break;
if (i % remain == 0) {
tmp /= 10;
} else {
break;
}
}
if (tmp == 0) {
res.push_back(i);
}
}
return res; // 屏蔽掉竟然能出正常结果,很神奇???
}