Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- int main()
- {
- char s[100];
- for (int i = 0; i < 100; i++)
- {
- scanf("%c", &s[i]);
- if (s[i] == '\n')
- {
- s[i] == '\0';
- break;
- }
- }
- int a = 0, b = 0, c = 0;
- int t = 0;
- for (int i = 0; i < strlen(s); i++)
- {
- if (s[i] == '(')
- {
- a++;
- for (int j = t + 1; j < strlen(s); j++)
- {
- if (s[j] == ')')
- {
- b++;
- t = j;
- break;
- }
- }
- } else {
- if (s[i] == ')')
- c++;
- }
- }
- printf("a = %d, b = %d, c = %d\n", a, b, c);
- printf("%d\n", (a == b && c == b) ? 1 : 0);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement