Status Test( char *s ) ;
int main()
{
char s[200] ;
gets(s) ;
if( Test(s) )
printf("OK\n") ;
else
printf("Wrong\n") ;
return 0 ;
}
Status Test( char *s )
{
Stack S ;
char e ;
InitStack(S) ;
while( *s != '
Status Test( char *s ) ;
int main()
{
char s[200] ;
gets(s) ;
if( Test(s) )
printf("OK\n") ;
else
printf("Wrong\n") ;
return 0 ;
}
Status Test( char *s )
{
Stack S ;
char e ;
InitStack(S) ;
while( *s != '\0'){
if( *s == '(' || *s == '[' )
Push( S, *s ) ;
else if ( *s == ')'){
if( Pop(S,e) && e == '(' )
;
else
return ERROR ;
}
else if ( *s == ']'){
if( Pop(S,e) && e == '[' )
;
else
return ERROR ;
}
else
return ERROR ;
s ++ ;
}//end while
if( StackEmpty(S) )
return OK ;
else
return ERROR ;
}
'){
if( *s == '(' || *s == '[' )
Push( S, *s ) ;
else if ( *s == ')'){
if( Pop(S,e) && e == '(' )
;
else
return ERROR ;
}
else if ( *s == ']'){
if( Pop(S,e) && e == '[' )
;
else
return ERROR ;
}
else
return ERROR ;
s ++ ;
}//end while
if( StackEmpty(S) )
return OK ;
else
return ERROR ;
}
Status Test( char *s ) ;
int main()
{
char s[