Ответы - CodeHelperСписок последних 15 ответов на вопрос с сайта CodeHelperuuid:b96e72db-b716-4a7c-b7f9-c29638674c64;id=512012-09-26T09:51:19Zuuid:b96e72db-b716-4a7c-b7f9-c29638674c64;id=52Алгоритм поиска непарных скобок2010-06-16T08:20:35-05:002010-06-16T08:20:35-05:00AlexandrДобрый день. Есть задачка, подсчитать количество непарных скобок в тексте. То есть: есть открывающая скобка, но закрывающую не поставили, следовательно она непарная.(ну это я так, просто для примера:)uuid:b96e72db-b716-4a7c-b7f9-c29638674c64;id=53Ответ от Sergey на вопрос с сайта CodeHelper2010-06-16T09:38:06-05:002010-06-16T09:38:06-05:00SergeyВот пример на C: Пример: Проверка правильности расстановки скобок v1 Файл Main.cpp #include "stdafx.h" namespace mystack { int stack_head = 0; const int stack_max_length = 128; char stack_holder[stack_max_length]; void error(char *message) { printf("Error: %s", message); abort();uuid:b96e72db-b716-4a7c-b7f9-c29638674c64;id=54Ответ от Alexander на вопрос с сайта CodeHelper2010-06-17T10:24:52-05:002010-06-17T10:24:52-05:00Alexanderfunction IsBracketsHavePair(text: string): boolean; var counter, i: integer; begin result := false; counter := 0; for i := 1 to Lenght(text) - 1 do begin if text[i] = '(' then counter := counter + 1; if text[i] = ')' then counter := counter - 1; if counter < 0 then break; end if counter = 0 then