SHARE
TWEET

Untitled

a guest Oct 21st, 2019 109 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main()
  5. {
  6.     char s[100];
  7.     for (int i = 0; i < 100; i++)
  8.     {
  9.         scanf("%c", &s[i]);
  10.         if (s[i] == '\n')
  11.         {
  12.             s[i] == '\0';
  13.             break;
  14.         }
  15.     }
  16.  
  17.     int a = 0, b = 0, c = 0;
  18.     int t = 0;
  19.     for (int i = 0; i < strlen(s); i++)
  20.     {
  21.         if (s[i] == '(')
  22.         {
  23.             a++;
  24.             for (int j = t + 1; j < strlen(s); j++)
  25.             {
  26.                 if (s[j] == ')')
  27.                 {
  28.                     b++;
  29.                     t = j;
  30.                     break;
  31.                 }
  32.             }
  33.         } else {
  34.             if (s[i] == ')')
  35.                 c++;
  36.         }
  37.     }
  38.  
  39.     printf("a = %d, b = %d, c = %d\n", a, b, c);
  40.     printf("%d\n", (a == b && c == b) ? 1 : 0);
  41.     return 0;
  42. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top