ans

wyz2011 2023-12-09 15:08:16 7 返回题目

#include<bits/stdc++.h>
using namespace std;
stack<char> a;
int main(){
	char n;
	while(cin>>n){
		if(n=='(') a.push(n);
		if(n=='[') a.push(n);
		if(n==']'){
			if(a.size()>0&&a.top()=='[')
				a.pop();
			else a.push(n);
		}
		if(n==')'){
			if(a.size()>0&&a.top()=='(')
				a.pop();
			else a.push(n);
		}
	}
	if(a.size()==0) cout<<"OK";
	else cout<<"Wrong";
    return 0;
}
{{ vote && vote.total.up }}