您的位置:首页 > 其它

Notes2

2015-08-12 22:16 435 查看
UVa 340

#include <stdio.h>
#define MAX 1020
int main()
{
int n, i, cas = 1;
int code[MAX], guess[MAX], hash1[20], hash2[20];
while(1)
{
scanf("%d", &n);
if(!n) break;
for(i = 0; i < n; i++)
scanf("%d", &code[i]);
printf("Game %d:\n", cas++);
while(1)
{
for(i = 0; i < n; i++)
scanf("%d", &guess[i]);
if(guess[0] == 0)
break;
int strong = 0, weak = 0;
memset(hash1, 0, sizeof(hash1));
memset(hash2, 0, sizeof(hash2));
for(i = 0; i < n; i++)
{
if(code[i] == guess[i]) strong++;
else
{
hash1[code[i]]++;
hash2[guess[i]]++;
}
}
for(i = 1; i < 10; i++)
weak += (hash1[i] < hash2[i])? hash1[i] : hash2[i];
printf("    (%d,%d)\n", strong, weak);
}
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: