homework - #12
Conversation
| } | ||
| std::vector<std::string> SplitString(const std::string& data, const char& del) { | ||
| std::vector <std::string> allstrings; | ||
| std::string onestring = ""; |
There was a problem hiding this comment.
я бы назвал one_string, но как-то название тоже не очень, возможно word или что-то подобное лучше будет
| std::vector<std::string> SplitString(const std::string& data, const char& del) { | ||
| std::vector <std::string> allstrings; | ||
| std::string onestring = ""; | ||
| std::string brackets = { '(', ')' }; |
There was a problem hiding this comment.
интересное решение, yj я бы добавил const
| std::vector <std::string> allstrings; | ||
| std::string onestring = ""; | ||
| std::string brackets = { '(', ')' }; | ||
| bool in_brackets = 0; |
There was a problem hiding this comment.
bool in_brackets = true;
присвоение bool'у нуля смотрится так себе
| { | ||
| onestring.push_back(symbol); | ||
| allstrings.push_back(onestring); | ||
| onestring = ""; |
There was a problem hiding this comment.
onestring.clear() смотрится лучше
| onestring.push_back(symbol); | ||
| allstrings.push_back(onestring); | ||
| onestring = ""; | ||
| in_brackets = 0; |
| int Calculate(const std::string& data) | ||
| { | ||
| int i = 0; | ||
| int a = 0; |
There was a problem hiding this comment.
полохое название переменной
намного лучше выглядит например left_number, но кажется можно и лучше придумать
| } | ||
| int Calculate(const std::string& data) | ||
| { | ||
| int i = 0; |
There was a problem hiding this comment.
это индекс, так что лучше использовать size_t
| { | ||
| int i = 0; | ||
| int a = 0; | ||
| while (isdigit(data[i])&& i < data.length()) |
| else if (operation == "/") | ||
| return a / b; | ||
| else | ||
| return 36606; |
There was a problem hiding this comment.
а что за магическое число? что оно значит?
| b += int(data[i]) - 48; | ||
| i++; | ||
| } | ||
| if (operation == "+") |
There was a problem hiding this comment.
тут лучше бы смотрелся switch
No description provided.