求助,WA了。
查看原帖
求助,WA了。
511907
一只大龙猫楼主2021/12/11 17:12

RT,样例过了。

#include<iostream>
#include<map>
#include<string>
using namespace std;
int rd;
void work(){
	map<char,bool> app,gue;//表示是否出现和是否猜错 
	string s1,s2;
	int cnt=0,no_gue=0;//猜错的次数,还没猜到的字母数 
	cin>>s1>>s2;
	for(int i=0;i<s1.size();i++){
		if(!app[s1[i]]){
			app[s1[i]]=1;
			no_gue++;
		}
	} 
	for(int i=0;i<s2.size();i++){
		if(!app[s2[i]]||gue[s2[i]]){
			cnt++;
			if(cnt>=7){
				cout<<"You lose."<<endl;
				return;
			}
		}else{
			gue[s2[i]]=1;
			no_gue--;
		}
	}
	if(no_gue==0){
		cout<<"You win.";
	}else{
		cout<<"You chickened out.";
	}
	cout<<endl;
	return;
}
int main(){
	cin>>rd;
	while(rd!=-1){
		cout<<"Round "<<rd<<endl;
		work();
		cin>>rd;
	}
	return 0;
}
2021/12/11 17:12
加载中...