UVA340
来源:互联网 发布:淘宝网法院拍卖 编辑:程序博客网 时间:2024/06/10 07:58
相同位置又相同数字,A就加1,在不同位置数字相同,就B加1。。匹配过一次不能再匹配第二次。。把他标记一下,或变成0就行。。。
AC代码:
#include<cstdio>#include<cstring>int main () {int flag = 0;int A,B;int n;int num;int top[1000],key[1000],temp[1000];while (scanf( "%d", &n )) {if (n == 0)break;memset ( top , 0 ,sizeof ( top ));printf("Game %d:\n",++flag);for (int i = 0 ; i < n ; i++) {scanf( "%d" ,&top[i]);}num = 0;while (1) {memset ( key , 0 ,sizeof ( key ));memset ( temp , 0 ,sizeof ( temp ));for (int i = 0 ; i < n ;i++) {scanf ("%d" ,&key[i]);temp[i] = top[i];if (key[i] == 0)++num;}if (num == n )break;A = 0;B = 0;for (int i = 0; i < n; i++) {if (key[i] == temp[i]) {++A;key[i] = 0;temp[i] = 0;}}for (int i = 0; i < n ; i++) {if (key[i] != 0) {for ( int j = 0; j < n ;j++) {if (key[i] == temp[j]) {++B;key[i] = 0;temp[j] = 0; break;}}}}printf(" (%d,%d)\n",A,B);}}return 0;}
0 0
- uva340
- UVA340
- UVa340
- uva340
- UVa340
- uva340 - Master-Mind Hints
- UVa340 Master-Mind Hints
- UVA340 - Master-Mind Hints
- UVA340 Master-Mind Hints
- uva340 - Master-Mind Hints
- UVA340 - Master-Mind Hints
- UVa340 Master-Mind Hints
- uva340 Master-Mind Hints
- UVa340-Master-Mind Hints
- UVa340 Master-Mind Hints
- uva340 数字匹配检索问题
- UVA340 UVALive5448 Master-Mind Hints
- Master-Mind Hints—UVa340
- 最小堆模板类 面试必备
- UVA 575 (暑假-数论 -A - Skew Binary)
- UVA 550 (暑假-数论 -B - Multiplying by Rotation)
- 《剑指offer》解题笔记
- POJ 1012(约瑟夫问题)
- UVA340
- C语言:assert()函数用法总结
- iOS音频播放 (三):AudioFileStream
- UVA568 (暑假-数论 -C - Just the Facts)
- XSS之xssprotect
- oracle 命令汇总
- UVA408 (暑假-数论 -D - Uniform Generator)
- spring静态注入组件——工具类常用
- poj1260