int match(char a[],int n)
{
	char sq[maxSize];
	int top=-1;
	for(int i=0;i<n;i++)
	{
		if(a[i]=='(')
			sq[++top]=a[i];
		if(a[i]=='[')
			sq[++top]=a[i];
		if(a[i]==')')
		{
			if(top==-1)
				return 0;
			if(sq[top]=='(')
				--top;
		}
		if(a[i]==']')
		{
			if(top==-1)
				return 0;
			if(sq[top]=='[')
				--top;
		}
	}
	if(top==-1)
		return 1;
	else
		return 0;
}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-11
  • 2021-09-01
猜你喜欢
  • 2022-01-06
  • 2021-06-01
  • 2021-12-14
  • 2022-01-31
  • 2022-12-23
  • 2021-07-29
  • 2022-12-23
相关资源
相似解决方案