Skip to content

homework - #12

Open
arzaaam wants to merge 4 commits into
DafeMipt212:mainfrom
arzaaam:homework
Open

homework#12
arzaaam wants to merge 4 commits into
DafeMipt212:mainfrom
arzaaam:homework

Conversation

@arzaaam

@arzaaam arzaaam commented Dec 10, 2022

Copy link
Copy Markdown

No description provided.

}
std::vector<std::string> SplitString(const std::string& data, const char& del) {
std::vector <std::string> allstrings;
std::string onestring = "";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

я бы назвал 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 = { '(', ')' };

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

интересное решение, yj я бы добавил const

std::vector <std::string> allstrings;
std::string onestring = "";
std::string brackets = { '(', ')' };
bool in_brackets = 0;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

bool in_brackets = true;
присвоение bool'у нуля смотрится так себе

{
onestring.push_back(symbol);
allstrings.push_back(onestring);
onestring = "";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

onestring.clear() смотрится лучше

onestring.push_back(symbol);
allstrings.push_back(onestring);
onestring = "";
in_brackets = 0;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

false

int Calculate(const std::string& data)
{
int i = 0;
int a = 0;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

полохое название переменной
намного лучше выглядит например left_number, но кажется можно и лучше придумать

}
int Calculate(const std::string& data)
{
int i = 0;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

это индекс, так что лучше использовать size_t

{
int i = 0;
int a = 0;
while (isdigit(data[i])&& i < data.length())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

пробел пропущен

else if (operation == "/")
return a / b;
else
return 36606;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

а что за магическое число? что оно значит?

b += int(data[i]) - 48;
i++;
}
if (operation == "+")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

тут лучше бы смотрелся switch

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