Skip to content

Feature/solve first homework - #1

Open
ArtEnjoyer wants to merge 3 commits into
mainfrom
feature/solve_first_homework
Open

Feature/solve first homework#1
ArtEnjoyer wants to merge 3 commits into
mainfrom
feature/solve_first_homework

Conversation

@ArtEnjoyer

Copy link
Copy Markdown
Owner

commitariy

@ArtEnjoyer
ArtEnjoyer force-pushed the feature/solve_first_homework branch from 9065338 to 7e91fd4 Compare November 12, 2022 08:28
#include <stack>
#include <string>
#include <vector>
using namespace std;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

using namespace - плохая практика

using namespace std;
std::vector<std::string> SplitString(const std::string& data) {
return {};
std::vector<std::string> v;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

v - плохое имя для переменной

return {};
std::vector<std::string> v;
std::string buff = "";
bool flag = false; //скобки закрыты (или их нет)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

std::vector<std::string> v;
std::string buff = "";
bool flag = false; //скобки закрыты (или их нет)
cout << size(data) << endl;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

думаю это отладка, лучше убрать после того как отладился

} else if (data[i] == ')') {
flag = false; //скобки закрыты
}
if (((data[i] != ' ') and (data[i] != '\t')) or (flag == true)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

В C++ не принято писать and и or, используй вместо && и ||

if (((data[i] != ' ') and (data[i] != '\t')) or (flag == true)) {
buff += data[i];
}
cout << "Data" << i << " : " << data[i] << endl;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

отладка?

}
} else {
if (i + 1 >= size(data)) {
if (buff != "") {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

!buff.empty()

if (i + 1 >= size(data)) {
if (buff != "") {
v.push_back(buff);
buff = "";

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

лучше buff.clear()

Comment thread homework_01/task_02/src/utils.cpp Outdated
if (str.empty()) flag= false;
for (size_t i=1;i<str.size();++i)
{
if ((str[i]>='0') && (str[i]<='9'))/* if (std::isdigit(str[i]))*/a=1;

Copy link
Copy Markdown

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