Advertisement
Avdluna

Untitled

Oct 20th, 2015
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.27 KB | None | 0 0
  1. #include <cstdio>
  2. #include <stack>
  3. #include <string.h>
  4.  
  5.                         using namespace std;
  6.  
  7.                     int main(){
  8.  
  9.                     char qwert[10001];
  10.                            
  11.  
  12.                            while(scanf("%s",qwert) != EOF){
  13.                            
  14.                             stack <int> pilha;
  15.                            
  16.                              bool jujuba = true;
  17.  
  18.                              for(int i=0 ; i < strlen(qwert) ; i++){
  19.  
  20.                                if(qwert[i] == '('){
  21.                                         pilha.push(1);
  22.                                }
  23.                                 else if(qwert[i] == ')'){
  24.  
  25.                                         pilha.pop();
  26.                                }
  27.  
  28.                                if(qwert[i] == ')' && pilha.empty()){
  29.  
  30.                                         jujuba = false;
  31.                                             printf("correct\n")
  32.                                }
  33.                                
  34.                                else{
  35.                                 printf("incorrect\n");
  36.                                }
  37.  
  38.  
  39.                              }
  40.  
  41.  
  42.                            }
  43.  
  44.  
  45.                                     return 0;
  46.                                          }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement