• UVA-340 Master-Mind Hints


     1 #include <iostream>
     2 #include <stdlib.h>
     3 #include <string>
     4 #include <vector>
     5 #include <algorithm>
     6 #include <string.h>
     7 #include <stack>
     8 #include <unordered_map>
     9 #include <math.h>
    10 
    11 using namespace std;
    12 
    13 int main()
    14 {
    15     int listLength;
    16     int tol = 1;
    17     while(cin >> listLength)
    18     {
    19         if(listLength==0)
    20             break;
    21 
    22         vector<int> correctList;
    23         vector<int> correctHash (10,0);
    24         for(int i = 0; i < listLength; i ++)
    25         {
    26             int tmp;
    27             cin >> tmp;
    28             correctList.emplace_back(tmp);
    29             correctHash[tmp] ++;
    30         }
    31 
    32         cout << "Game " << tol++ << ":" << endl;
    33         while(1)
    34         {
    35             vector<int> guessHash (10,0);
    36             int A = 0,B = 0;
    37             int flag = 0;
    38             for(int i = 0; i < listLength; i ++)
    39             {
    40                 int tmp;
    41                 cin >> tmp;
    42                 if(tmp==0)
    43                 {
    44                     flag = 1;
    45                 }
    46                 else
    47                 {
    48                     if(tmp==correctList[i])
    49                         A ++;
    50                     guessHash[tmp] ++;
    51                 }
    52             }
    53             if(flag)
    54                 break;
    55             for(int i = 1; i <= 9; i ++)
    56             {
    57                 B += min(correctHash[i],guessHash[i]);
    58             }
    59             cout << "    (" << A << "," << B-A << ")" << endl;
    60         }
    61     }
    62     return 0;
    63 }
  • 相关阅读:
    各种贴图
    d3d11devicecontext
    小记2
    Tom Ryaboi
    Tessellation
    关于图形学
    第一章实验
    控制输入框只接收数字及小数点
    JQuery控制文本框是否可以输入
    SQLSERVER中查询一个存储过程使用到的地方
  • 原文地址:https://www.cnblogs.com/Asurudo/p/9591155.html
Copyright © 2020-2023  润新知