Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 401df77

Browse files
Add C++ solution of problem #1317
1 parent ef64044 commit 401df77

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

‎1317/solution.cpp‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
class Solution {
2+
public:
3+
vector<int> getNoZeroIntegers(int n) {
4+
for(int a = 1; a <= n - 1; a++) {
5+
int b = n - a;
6+
if(!hasZero(a) && !hasZero(b))
7+
return {a, b};
8+
}
9+
throw;
10+
}
11+
12+
private:
13+
bool hasZero(int n) {
14+
while(n) {
15+
int digit = n % 10;
16+
if(digit == 0)
17+
return true;
18+
n /= 10;
19+
}
20+
return false;
21+
}
22+
};

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /