UVa489 Hangman Judge
程序员文章站
2024-03-19 08:20:10
...
题目传送门:https://vjudge.net/problem/UVA-489
题目很简单,不需要思路。
暴力解决,直接上代码:
#include<stdio.h>
#include<string.h>
int death;
char str0[1001];
char str1[1001];
int judge(char* str1, char * str2) {
int left = strlen(str1);
for(int i = 0; i < strlen(str2); i++) {
int mark = 0;
for(int j = 0; j < strlen(str1); j++) {
if(str2[i] == str1[j]) {
str1[j] = ' ';
mark = 1;
left--;
}
}
if(!mark)
death++;
if(death == 7)
return 3;
if(!left)
return 1;
}
return 2;
}
int main() {
int n;
memset(str0, '\0', sizeof(str0));
memset(str1, '\0', sizeof(str1));
while(~scanf("%d", &n)) {
if(n == -1) break;
death = 0;
scanf("%s%s", str0, str1);
printf("Round %d\n", n);
int result = judge(str0, str1);
if(result == 1) printf("You win.");
if(result == 2) printf("You chickened out.");
if(result == 3) printf("You lose.");
printf("\n");
memset(str0, '\0', sizeof(str0));
memset(str1, '\0', sizeof(str1));
}
return 0;
}
上一篇: 【SSL1230】战略游戏
推荐阅读
-
UVa489 Hangman Judge
-
UVA - 12169 Disgruntled Judge
-
Virtual Judge 系统开发二:提交模块
-
Python实现的简单hangman游戏实例
-
Python实现的简单hangman游戏实例
-
Python 实现 Hangman 小游戏
-
『ACM C++』Virtual Judge | 两道基础题 - The Architect Omar && Malek and Summer Semester
-
关于CCR测评器的自定义校验器(Special Judge)
-
Python实现的简单hangman游戏实例
-
LeetCode997.Find the Town Judge(找到小镇的法官)