Skip to content

Instantly share code, notes, and snippets.

@joaogui1
Created June 21, 2016 00:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joaogui1/96fcbb75ae5e324fa19250785fadde05 to your computer and use it in GitHub Desktop.
Save joaogui1/96fcbb75ae5e324fa19250785fadde05 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
int main(){
char a;
while(scanf(" %c", &a)!=EOF){
int cor = 1 ,par=0, clospar=0;
while(1){
if (a=='(') par++;
else if (a==')') clospar++;
if (clospar > par) cor = 0;
a=getchar();
if(a=='\n'){
break;
}
}
if(par == clospar && cor) printf("correct\n");
else printf("incorrect\n");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment