Untitled
unknown
plain_text
5 years ago
557 B
7
Indexable
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
char stack[102 * 1024];
signed main() {
char c;
int top = 0;
while ((c = getc(stdin)) != EOF) {
if (c == '[')
stack[top++] = ']';
else if (c == '<')
stack[top++] = '>';
else if (c == '{')
stack[top++] = '}';
else if (c == '(')
stack[top++] = ')';
else if (top && c == stack[top - 1])
--top;
else {
printf("NO");
return 0;
}
}
if (!top)
printf("YES");
else
printf("NO");
}Editor is loading...