求助
查看原帖
求助
359642
Chromedome楼主2020/12/16 21:05

在IDE中试验了,输入空串后啥么都没有返回!(本人非常不解,所以来请教一下大佬们)

代码:

#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	for(int x=0; x<n; x++){
		string c;
		int sn=0, mn=0;
		cin>>c;
		for(int i=0; i<c.length(); i++){
			if(c[i]=='('){
				sn++;
			}else if(c[i]=='['){
				mn++;
			}else if(c[i]==')'){
				sn--;
			}else if(c[i]==']'){
				mn--;
			}
		}
		if(sn==0 && mn==0){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}
	return 0;
}

我的预期本来是:空串中无任何括号,所以sn和mn变量应该都是零,但结果是啥都没输出!

P.S.那位热心大佬能告诉我一下RemoteJudge 怎么注册?

2020/12/16 21:05
加载中...