Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* MIPT, task # 008
- "Brackets"
- 13.09.2011
- */
- #include <stdio.h>
- #define MAX_STR_LENGTH 4000
- int main()
- {
- char s[MAX_STR_LENGTH];
- gets (s);
- int balance = 0;
- char *cur = s;
- while (*cur) {
- if ('(' == *cur) {
- ++balance;
- } else {
- --balance;
- }
- if (balance < 0) {
- puts ("NO");
- exit (0);
- }
- ++cur;
- }
- if (!balance) {
- puts ("YES");
- } else {
- puts ("NO");
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment