[]
<[]<[]>>
() ()
void parens (void) (
for (;; ) (
switch (lookahead) (
case '(' :
M( '(' ) : paren (); M( ')' ); continue;
case '<' :
M( '<' ) : paren (); M( '>' ); continue;
case '[' :
M( '[' ) : paren (); M( ']' ); continue;
Default;
Return;
}
}
}هذا الكود في السي ادخل سترينج
مثلا ادخل ( لازم يعطيني )
ادخل < يعطيني >
ادخل [ يعطيني ]
The program checks whether an input string is balanced ; that is , if each opening parenthesis has a matching closing parenthesis .For the purposes of this exercise , brackets ,[ and ] , and the symbols < and > will also be referred to as parentheses . Any enclosed substrings must them selves be balanced . Complete the program by giving as implementation for procedure M and supplying an appropriate procedure main . The program must produce as output the string balanced if the input string consists of balanced parentheses .