Skip to content

Add stack module and brackets checker program#19

Open
Quark1111 wants to merge 6 commits intomainfrom
brackets_checker
Open

Add stack module and brackets checker program#19
Quark1111 wants to merge 6 commits intomainfrom
brackets_checker

Conversation

@Quark1111
Copy link
Owner

No description provided.

@Quark1111 Quark1111 requested a review from chernishev November 24, 2025 12:02

Choose a reason for hiding this comment

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

Надо удалить лишние файлы

Comment on lines +16 to +33
case ']':
if (get(&ScobStruct, '['))
pop(&ScobStruct);
else
flag = 0;
break;
case ')':
if (get(&ScobStruct, '('))
pop(&ScobStruct);
else
flag = 0;
break;
case '}':
if (get(&ScobStruct, '{'))
pop(&ScobStruct);
else
flag = 0;
break;

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.

Надо задачу решать полностью в одной ветке. А то комменатрии теряются

flag = 0;
break;
default:
if (InputString[i] == '(' || InputString[i] == '[' || InputString[i] == '{')

Choose a reason for hiding this comment

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

Нет, вот так точно не делается. Если используете switch, то надо все варианты прописать как case. Понятно, что хочется pattern matching, но в C его нет, и не должно быть (за счёт того, что switch работает только с целочисленными типами).

Подсказка: switch умеет проваливаться, и этим надо воспользоваться.

#include <stdlib.h>
#include "stack.h"

void push(stack *begin, char c) {

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