//UVa340 Master-Mind Hints
#include<stdio.h>
#define max 105
int main(){
//freopen("date.in","r",stdin);
int n, a[max], b[max];
int kase = 0;
while(scanf("%d",&n) == 1 && n){ //n=0 时结束循环
printf("Game%d:\n",++kase);
//答案序列
for(int i = 0; i < n; i++)
scanf("%d",&a[i]);
//猜测序列
while(1){
int A = 0, B = 0;
//获取并计算A
for(int i = 0; i<n; i++){
scanf("%d",&b[i]);
if(a[i]==b[i]) A++;
}
//内循环出口条件,游戏切换
if(b[0] == 0) break;
//计算A+B的值
for(int d = 1; d <= 9; d++){
int c1 = 0, c2 = 0;
for(int i = 0; i < n; i++){
if(a[i] == d) c1++;
if(b[i] == d) c2++;
}
if(c1 < c2) B += c1;else B += c2;
}
printf(" (%d,%d)\n", A, B-A);
//continue 下一场游戏,下一个猜测序列
}
//新的游戏
}
return 0;
}
/*
DATE IN:
4
1 3 5 5
1 1 2 3
4 3 3 5
6 5 5 1
6 1 3 5
1 3 5 5
0 0 0 0
10
1 2 2 2 4 5 6 6 6 9
1 2 3 4 5 6 7 8 9 1
1 1 2 2 3 3 4 4 5 5
1 2 1 3 1 5 1 6 1 9
1 2 2 5 5 5 6 6 6 7
0 0 0 0 0 0 0 0 0 0
0
-------------------
DATE OUT:
Game1:
(1,1)
(2,0)
(1,2)
(1,2)
(4,0)
Game2:
(2,4)
(3,2)
(5,0)
(7,0)
*/
UVa340 Master-Mind Hints
程序员文章站
2024-02-24 22:29:46
...
下一篇: 分别使用C和C++判断字符串回文
推荐阅读
-
uva 340 - Master-Mind Hints
-
UVa 340 - Master-Mind Hints
-
UVa340 Master-Mind Hints
-
Master-Mind Hints UVA - 340
-
基于hints是oracle 优化方案
-
五分钟精通Oracle Hints
-
微信{"errcode":48001,"errmsg":"api unauthorized, hints: [ req_id: 1QoCla0699ns81 ]"}
-
微信{"errcode":48001,"errmsg":"api unauthorized, hints: [ req_id: 1QoCla0699ns81 ]"}
-
Python类型提示Type Hints示例详解
-
推荐一个程序员必备网站之一:Dev Hints ,非常实用!