Update a1/program.c

This commit is contained in:
Yurii Chechur 2024-10-24 20:18:29 +00:00
parent 5128e156ff
commit 8fbc2f9afb

View File

@ -21,9 +21,11 @@ int main() {
char stack[100]; char stack[100];
int top = -1; int top = -1;
//printf("Введіть код: "); // printf("");
fgets(input, 101, stdin); fgets(input, 101, stdin);
printf("Read: %s", input);
for (int i = 0; i < strlen(input); i++) { for (int i = 0; i < strlen(input); i++) {
char current = input[i]; char current = input[i];
@ -40,11 +42,11 @@ int main() {
return 1; return 1;
} }
if (!isMatching(stack[top], current)) { if (!isMatching(stack[top], current)) {
printf("Crossed bracket '%c' in %d , expected \n", printf("Crossed bracket '%c' in %d , expected \n", current, i);
(stack[top] == '{') ? '}' : (stack[top] == '{') ? '}' :
(stack[top] == '[') ? ']' : (stack[top] == '[') ? ']' :
(stack[top] == '(') ? ')' : '>', (stack[top] == '(') ? ')' : '>',
current, i); current, i;
return 1; return 1;
} }
top--; top--;