Advertisement
Guest User

Untitled

a guest
Dec 12th, 2018
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. /* run this program using the console pauser or add your own getch, system("pause") or input loop */
  5.  
  6. int main(int argc, char *argv[]) {
  7. char s[50];
  8. int nr=0,i;
  9. fgets(s,50,stdin);
  10. for(i=0; i<strlen(s); i++)
  11. {
  12. if(s[i]=='(')
  13. nr++;
  14. else
  15. if(s[i]==')')
  16. nr--;
  17. if(nr<0)
  18. break;
  19. }
  20. if(nr==0)
  21. printf("1");
  22. else
  23. printf("0");
  24.  
  25.  
  26.  
  27. return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement