UVa340 Master-Mind Hints
来源:互联网 发布:数据库pdforacle网盘 编辑:程序博客网 时间:2024/04/18 12:33
//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;//获取并计算Afor(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:41 3 5 51 1 2 34 3 3 56 5 5 16 1 3 51 3 5 50 0 0 0101 2 2 2 4 5 6 6 6 91 2 3 4 5 6 7 8 9 11 1 2 2 3 3 4 4 5 5 1 2 1 3 1 5 1 6 1 91 2 2 5 5 5 6 6 6 70 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)*/
0 0
- 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 UVALive5448 Master-Mind Hints
- Master-Mind Hints—UVa340
- Master-Mind Hints UVa340 排序&&查找
- UVa340——Master-Mind Hints
- 340 - Master-Mind Hints
- uva_340 - Master-Mind Hints
- uva_340 - Master-Mind Hints
- 340 - Master-Mind Hints
- 349. Intersection of Two Arrays [LeetCode]
- C. Timofey and a tree
- BZOJ1018——[SHOI2008]堵塞的交通traffic
- leetcode 36. Valid Sudoku
- jquery概览
- UVa340 Master-Mind Hints
- g2o库文件已上传
- 为什么年轻人越来越反感「亲戚」这群人?
- 1px像素的实现
- 老人是真饿了
- 算法训练 大小写转换
- 130. Surrounded Regions
- c++和c的头文件区分
- 编写更好的 Java 单元测试的 7 个技巧