Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bracket sequence #9

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open

Bracket sequence #9

wants to merge 12 commits into from

Conversation

viktoriia-fomina
Copy link
Owner

I made a function that checks if bracket sequence is correct. The function uses stack in implementation

Copy link

@yurii-litvinov yurii-litvinov left a comment

Choose a reason for hiding this comment

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

И тут ещё надо поправить стек в соответствии с замечаниями к 6.1

{
return false;
}
return true;

Choose a reason for hiding this comment

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

Это надо в одну строчку писать

Choose a reason for hiding this comment

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

Напоминаю :)

else
{
return false;
}

Choose a reason for hiding this comment

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

И это

return true;
}
return false;
}

Choose a reason for hiding this comment

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

И даже это :)

bool result = ifBracketSequenceIsCorrect(s);
cout << "res is " << result << endl;

system("pause");

Choose a reason for hiding this comment

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

Нельзя :)

Copy link

@yurii-litvinov yurii-litvinov left a comment

Choose a reason for hiding this comment

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

Я чуть не забыл, но надо ещё тесты :)
И желательно прописать в опциях проекта, чтобы консоль не закрывалась

if (!isEmpty())
{
newElement->next = head;
}

Choose a reason for hiding this comment

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

В принципе, если стек пуст, то head у него nullptr, так что newElement->next = head; ничего плохого не сделает и проверка не нужна. Но как у Вас --- более читабельно и логично, поэтому тоже ок.

{
return false;
}
return true;

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