求
  • 板块灌水区
  • 楼主lucy2012
  • 当前回复5
  • 已保存回复5
  • 发布时间2024/5/4 18:54
  • 上次更新2024/5/4 20:26:04
查看原帖
求
1252442
lucy2012楼主2024/5/4 18:54

T96987进不了讨论区,求调QwQ

#include<bits/stdc++.h>
using namespace std;
string c;
stack<char> s;
int main(){
    cin>>c;
    int num=0;
    while(1){
    	if(c[num]=='@')
    	    break;
    	else if(c[num]=='('||c[num]=='['||c[num]=='{')
    		s.push(c[num]);
		else if((!s.empty()&&s.top()=='('&&c[num]==')')||(!s.empty()&&s.top()=='['&&c[num]==']')||(!s.empty()&&s.top()=='{'&&c[num]=='}'));
			s.pop();
		num++;
	}
	if(s.empty())
	    cout<<"YES";
	else
	    cout<<"NO";
    return 0;
}
2024/5/4 18:54
加载中...