40分求救!!【红题】
查看原帖
40分求救!!【红题】
549426
ttkuilei楼主2021/8/29 19:51

P1739 表达式括号匹配

#include<iostream>
#include<string>
using namespace std;
int main() {
	string bds;
	cin>>bds;
	int i=0;
	for(int j=0;j<bds.size();j++) {
		if(bds[j]='(') i++;
		if(bds[j]=')'&&i) i--;
	}
	if(i) cout<<"NO";
	else cout<<"YES";
	return 0;
}
2021/8/29 19:51
加载中...