玄3关 关于stoi()
查看原帖
玄3关 关于stoi()
1365127
dendky楼主2025/1/19 11:50
#include <bits/stdc++.h>
using namespace std;
string s[100005], ss[100005];
map <string, int>check;
bool flag[100005];
int main(){
	int n;
	cin>>n;
	for (int i=1; i<=n; i++){
		cin>>s[i];
		check[s[i]]++;
	}
	int m;
	cin>>m;
	for (int i=1; i<=m; i++){
		cin>>ss[i];
		int a=stoi(ss[i], 0, 10);//报错RE
		if (check[ss[i]]==1) cout<<"OK"<<"\n";
		else if (check[ss[i]]==2 && flag[a]==0){
			cout<<"REPEAT"<<"\n";
			flag[a]=1;
		}else cout<<"NO"<<"\n";
	}
	return 0;
}

该函数的介绍,然后我就把他用在代码里了,但是爆了RE,思路就是把ss[i]ss[i]转成intint类型用flag[ss[i]]flag[ss[i]]标记

求报错原因,求调

2025/1/19 11:50
加载中...