Skip to content

Commit 2b2d126

Browse files
authored
Update equal-rational-numbers.cpp
1 parent 1dbb3d1 commit 2b2d126

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

C++/equal-rational-numbers.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,21 +86,21 @@ class Solution {
8686
}
8787

8888
Fraction result(stol(S.substr(0, i)), 1);
89-
const auto& non_repeat_part = S.substr(i + 1);
90-
i = non_repeat_part.find('(');
89+
const auto& non_int_part = S.substr(i + 1);
90+
i = non_int_part.find('(');
9191
if (i == string::npos) {
92-
if (!non_repeat_part.empty()) {
93-
result += Fraction(stol(non_repeat_part),
94-
static_cast<int64_t>(pow(10, non_repeat_part.length())));
92+
if (!non_int_part.empty()) {
93+
result += Fraction(stol(non_int_part),
94+
static_cast<int64_t>(pow(10, non_int_part.length())));
9595
}
9696
return result;
9797
}
9898

9999
if (i > 0) {
100-
result += Fraction(stol(non_repeat_part.substr(0, i)),
100+
result += Fraction(stol(non_int_part.substr(0, i)),
101101
static_cast<int64_t>(pow(10, i)));
102102
}
103-
const auto& repeat_part = non_repeat_part.substr(i + 1, non_repeat_part.length() - i - 2);
103+
const auto& repeat_part = non_int_part.substr(i + 1, non_int_part.length() - i - 2);
104104
result += Fraction(stol(repeat_part),
105105
static_cast<int64_t>(pow(10, i)) *
106106
(static_cast<int64_t>(pow(10, repeat_part.length())) - 1));

0 commit comments

Comments
 (0)