mirror of
https://hub.njuu.cf/TheAlgorithms/C-Plus-Plus.git
synced 2023-10-11 13:05:55 +08:00
Merge pull request #2 from wwells4/patch-2
Update Paranthesis Matching.cpp
This commit is contained in:
commit
3465588929
@ -19,7 +19,7 @@ char pop()
|
||||
|
||||
bool check(char x, char y)
|
||||
{
|
||||
if ( ( x=='(' && y==')' ) || ( x=='{' && y=='}' ) || ( x=='[' && y==']' ) || ( x=='<' && y=='>' ) )
|
||||
if ((x=='(' && y==')') || (x=='{' && y=='}') || (x=='[' && y==']') || (x=='<' && y=='>'))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -38,12 +38,11 @@ int main()
|
||||
gets(exp);
|
||||
for (int i = 0; i < strlen(exp); i++)
|
||||
{
|
||||
if (exp[i]=='(' || exp[i]=='{' || exp[i]=='[' || exp[i]=='<')
|
||||
if (exp[i]=='(' || exp[i]=='{' || exp[i]=='[' || exp[i]=='<')
|
||||
{
|
||||
push(exp[i]);
|
||||
//show();
|
||||
}
|
||||
else if (exp[i]==')' || exp[i]=='}' || exp[i]==']' || exp[i]=='>')
|
||||
else if (exp[i]==')' || exp[i]=='}' || exp[i]==']' || exp[i]=='>')
|
||||
{
|
||||
if(!check(pop(), exp[i]))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user