Skip to content

02 ternary numbers#3

Open
wizir6 wants to merge 9 commits intoSBoyNumber1:masterfrom
wizir6:02_ternary_numbers
Open

02 ternary numbers#3
wizir6 wants to merge 9 commits intoSBoyNumber1:masterfrom
wizir6:02_ternary_numbers

Conversation

@wizir6
Copy link
Copy Markdown

@wizir6 wizir6 commented Jun 5, 2019

No description provided.

return result;
}

for (auto it = input.cbegin(); it != input.cend(); it++)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

auto воспользовался, а перечисляющим for нет :)

if (input.empty())
{
result = false;
return result;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return false

}
}

return result;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return true

for (uint i = 0; i < input.size(); i++)
{
ternary += std::stoi(input.substr(i, 1)) * pow(3, indexes);
indexes--;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--indexes

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Можно было сделать еще лучше и декрементить прямо в функции, но если делать это на отдельной строке без присваивания, то разницы между префиксным и постфиксными вариантами нет

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants