昨天写的,90分()
查看原帖
昨天写的,90分()
955954
Miracle_InDream楼主2024/1/5 23:39
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a;
	cin>>a;
	char b[100];
	int top=0;
	for(int i=0;i<a.length();i++)
	{
		if(a[i]=='(')
		{
			b[++top]=a[i];
		}
		else
		{
			if(a[i]==')')
			{
				if(b[top]=='(')
					top--;
			}
		}
	}
	if(top==0)
	{
		cout<<"YES";
	}
	else
	{
		cout<<"NO";
	}
	return 0;
}
2024/1/5 23:39
加载中...