From d7ee1284a2c4b6d6f1801f9b64a34fe82292942c Mon Sep 17 00:00:00 2001 From: Ivan Leichenko Date: Thu, 31 Oct 2024 18:42:10 +0100 Subject: [PATCH] missing all brackets a1 --- a1/program.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/a1/program.c b/a1/program.c index ea85b80..726173c 100644 --- a/a1/program.c +++ b/a1/program.c @@ -51,7 +51,15 @@ int main() if (top != -1) { - printf("Missing closing brackets: %c\n", (stack[top] == '(' ? ')' : stack[top] == '{' ? '}' : stack[top] == '[' ? ']' : '>')); + memset(input, 0, len); + sprintf(input,"Missing closing brackets: "); + len = strlen(input); + for (int i = 0; i <= top; i++) + { + input[len++] = (stack[i] == '(' ? ')' : stack[i] == '{' ? '}' : stack[i] == '[' ? ']' : '>'); + } + input[len] = 0; + printf("%s", input); return 0; }