【例题4-2 uva489】Hangman Judge
例题
2023-09-14 09:03:44 时间
【链接】 我是链接,点我呀:)
【题意】
【题解】
水题。 中间就赢了算赢。(重复说,算错【代码】
#include <bits/stdc++.h>
using namespace std;
int _round;
string s1,s2;
int cnt[300];
int ok(string s){
int cur = 0;
for (int i = 0;i < (int)s.size();i++){
int temp = s[i]-'a';
if (cnt[temp]==0){
cur++;
if (cur==7)
return 0;
}else{
cnt[temp] = 0;
}
bool win = 1;
for (int j = 0;j < 26;j++) if (cnt[j]==1) win = 0;
if (win) return 1;
}
return -1;
}
int main()
{
//freopen("/home/ccy/rush.txt","r",stdin);
ios::sync_with_stdio(0),cin.tie(0);
while (cin >>_round){
for (int i = 0;i < 26;i++) cnt[i] = 0;
if (_round==-1) break;
cout<<"Round "<<_round<<endl;
cin >> s1;
for (int i = 0;i < (int)s1.size();i++) cnt[s1[i]-'a']=1;
cin >> s2;
int ju = ok(s2);
if (ju==0)
cout<<"You lose."<<endl;
else if(ju==1)
cout<<"You win."<<endl;
else cout<<"You chickened out."<<endl;
}
return 0;
}
相关文章
- C++ 用自定义函数验证高等数学的定积分例题
- 【例题4-3 uva 133】The Dole Queue
- 【例题 8-12 UVA-12627】Erratic Expansion
- 【例题 7-11 UVA - 12325】Zombie's Treasure Chest
- 【例题 7-8 UVA - 10603】Fill
- 【例题 7-3 UVA - 10976】Fractions Again?!
- 【例题 7-1 UVA - 725】Division
- 【例题 6-20 UVA - 1599】Ideal Path
- 【例题 6-5 UVA 12657 】Boxes in a Line
- 【例题5-8 UVA - 400】Unix ls
- ASP.NET MVC多表示例题-酒店管理
- 剑指offer 例题
- 例题(8.9) 打印水仙花数 (1041)
- 【数学建模】7 线性规划及例题详解
- 树状数组+例题
- 01背包+例题