UVA 340-Master-Mind Hints
来源:互联网 发布:数据产品运营专员 编辑:程序博客网 时间:2024/06/07 00:31
UVA 340-Master-Mind Hints
题目大意:一个猜数字的小游戏,同一位置猜对的话x+1,数字猜对,但位置不对的话y+1分,x优先
解题思路:用x,y变量表示就好
#include <stdio.h>#include <string.h>#include <iostream>using namespace std;int main() { int n; int all = 0; while(scanf("%d", &n) && n != 0) { all++; int a[1000]; int c[1000]; for(int i = 0; i < n; i++) scanf("%d", &a[i]); printf("Game %d:\n", all); int b[1000]; while(1) { int x = 0, y = 0; for(int i = 0; i < n; i++) { scanf("%d", &b[i]); c[i] = a[i]; } if(b[0] == 0) break; for(int i = 0; i < n; i++) { if(c[i] == b[i]) { x++; c[i] = 0; b[i] = 0; } } for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) { if(b[i] == 0) break; if(c[j] == b[i]) { y++; c[j] = 0; b[i] = 0; break; } } printf(" (%d,%d)\n", x, y); } } return 0;}
0 0
- UVa 340 Master-Mind Hints
- uva 340 Master-Mind Hints
- UVA 340 - Master-Mind Hints
- UVa 340 - Master-Mind Hints
- UVa 340 Master-Mind Hints
- UVA 340 Master-Mind Hints
- uva 340 Master-Mind Hints
- UVA 340 - Master-Mind Hints
- UVa 340 - Master-Mind Hints
- UVa 340 - Master-Mind Hints
- UVA 340 Master-Mind Hints
- uva 340 Master-Mind Hints
- UVa - 340 - Master-Mind Hints
- UVa 340 - Master-Mind Hints
- uva 340 Master-Mind Hints
- uva - 340 - Master-Mind Hints
- UVa 340 - Master-Mind Hints
- UVa:340 - Master-Mind Hints
- 最小调整有序
- Android四大组件生命周期
- leetcode题集——permutations
- c++——数组指针和指针数组
- websocket学习笔记
- UVA 340-Master-Mind Hints
- Beauty of Programming 1
- Objective-C属性字符串NSAttributedString
- c#——Winform DatagridView上显示下拉树(二)
- java中double类型的数保留两位小数的输出方法并且小数点前面是0的时候如何处理
- 20160714 数组
- 图解tomcat
- Node.js模块导出exports 和 module.exports 的区别
- 2016华为暑期实习生编程题之和尚挑水