Skip to content

Commit 41c1b30

Browse files
committedDec 26, 2018
Create 0728 - Solution
1 parent 2f3fe71 commit 41c1b30

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
class Solution {
2+
public:
3+
int div(int num){
4+
5+
int temp = num, r;
6+
7+
while( temp > 0 ){
8+
9+
r = temp % 10;
10+
11+
if( r == 0 || num % r != 0){
12+
return 0;
13+
}
14+
15+
temp /= 10;
16+
}
17+
18+
return 1;
19+
}
20+
21+
vector<int> selfDividingNumbers(int left, int right) {
22+
23+
vector<int> ret;
24+
25+
for(int i = left; i <= right; i++){
26+
if( div(i) ){
27+
ret.push_back(i);
28+
}
29+
}
30+
31+
return ret;
32+
}
33+
};

0 commit comments

Comments
 (0)