From 47f14d28dbada6cf98159c658e466091f4e2c950 Mon Sep 17 00:00:00 2001 From: Anton Dolozin Date: Mon, 13 Oct 2025 15:43:24 +0200 Subject: [PATCH] T --- a1/program.c | 42 +++++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/a1/program.c b/a1/program.c index 4ca8651..0de1d60 100644 --- a/a1/program.c +++ b/a1/program.c @@ -74,6 +74,25 @@ void read_input(LinkedNode** head){ { if(buff[i] == '[' || buff[i] == '<' || buff[i] == '{' || buff[i] == '('){ push(head, buff[i]);} + if(buff[i] == '[' || buff[i] == '<' || buff[i] == '{' || buff[i] == '(' && *head != NULL){ + if(buff[i] == '['){ + printf("Read: %sMissing closing brackets: ]", buff); + return; + } + if(buff[i] == '{'){ + printf("Read: %sMissing closing brackets: }", buff); + return; + } + if(buff[i] == '<'){ + printf("Read: %sMissing closing brackets: >", buff); + return; + } + if(buff[i] == '('){ + printf("Read: %sMissing closing brackets: 0", buff); + return; + } + + } if(buff[i] == '>' || buff[i] == '}' || buff[i] == ']' || buff[i] == ')'){ if(*head == NULL){ printf("Read: %sUnexpected closing bracket %c in %d\n", buff, buff[i], i); @@ -188,29 +207,6 @@ void read_input(LinkedNode** head){ } - } - if(*head != NULL){ - if (buff[i] == '[') - { - printf("Read: %sMissing closing brackets: ]\n", buff); - return; - } - if (buff[i] == '{') - { - printf("Read: %sMissing closing brackets: }\n", buff); - return; - } - if (buff[i] == '<') - { - printf("Read: %sMissing closing brackets: >\n", buff); - return; - } - if (buff[i] == '(') - { - printf("Read: %sMissing closing brackets: )\n", buff); - return; - } - } i++;