fork download
#include<iostream>
#define N 100

using namespace std;



struct ListNode{
           
     ListNode *link;
     bool tag;
     union{
       char data;    
       ListNode *dlink;    
           };
        
        }; 
        
 struct Stack{
       ListNode *stackarray[N];
       int sp;
       
       
       };       
Stack s;
     
int push(Stack *,ListNode *);
ListNode* pop(Stack *);
int isempty(Stack *); 
int isfull(Stack *);  
ListNode* create(char []);
        
int main(void){
    s.sp=-1;  
    
    
    ListNode* h=NULL;
    
    char input[50];
    cin>>input;
    h=create(input);
   
    cout<<h->data<<endl;
    
    
     system("pause");
     return 0;
    
    
}


ListNode* create(char string[] ){
          ListNode *p=new ListNode;
          ListNode *q;
          int i=0;
          char x;
          x=string[i++];
         
          do{
              switch(x){
                  case '(':      
                        x=string[i++];
                        p->tag=true;
                        if(x==')'){
                              p->dlink=NULL;    
                              if(!isempty(&s))     
                                 x=string[i++];  
                                   
                                   }
                       else{
                            p->dlink=new ListNode;
                            push(&s,p);
                            
                            } 
                        break;
                   case ')':
                        p->link=NULL;
                        p=pop(&s);
                           if(!isempty(&s))     
                           x=string[i++];   
                           break;
                           
                   case ',':
                        p->link=new ListNode;
                        p=p->link;
                        x=string[i++];
                        break;
                       
                   default:
                           p->tag=false;
                           p->data=x-48;
                           x=string[i++];            
                        
                        }        
                      
                      
                      }while(!isempty(&s));
          
          q=p->dlink;
          
          free(p);
          return q;
          
          
          }
          
          
int push(Stack *p,ListNode *x){
     if(isfull(p))
     return 1;
     p->sp++;
     p->stackarray[p->sp]=x;
     
     }
     
ListNode* pop(Stack *p){
     if(isempty(p))
     return NULL;
     else
     return p->stackarray[p->sp--];     
     
      
     } 
     
int isempty(Stack *p){
     if(p->sp==-1)
     return 1;
     else
     return 0;      
     }
          
int isfull(Stack *p){
    if(p->sp==N-1)   
    return 1;
    else
    return 0;   
}
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:46: error: ‘system’ was not declared in this scope
prog.cpp: In function ‘ListNode* create(char*)’:
prog.cpp:102: error: ‘free’ was not declared in this scope
stdout
Standard output is empty