Poj 2062 card game cheater

Source: Internet
Author: User

Two people play cards. The cards are 2, 3, 4... 9, T, J, Q, K, and a are sorted by the color of H> S> D> C if the number of points is equal. Tell you the first person's hand card, let you arrange the second person's hand card to maximize the score (compare the size of each card in order)

1 # include <iostream> 2 # include <algorithm> 3 # include <queue> 4 using namespace STD; 5 Int dot [300]; 6 int inputnum, numofcards, point; 7 int ADM [26], Eve [26]; 8 char str1, str2; // number of cards and pattern 9 void Init (); 10 void process (); 11 int main () 12 {13 // freopen ("D: \ t.txt", "r", stdin); 14 Init (); 15 process (); 16 return 0; 17} 18 void Init () {// initialize the data. Set the number of cards * 1019 dot ['T'] = 100; dot ['J'] = 110; dot ['q'] = 120; dot ['K'] = 130; dot ['a'] = 140; 20 For (INT m = 2; m <= 9; m ++) {21 dot [M + '0'] = m * 10; 22} 23 dot ['H'] = 4; dot ['s'] = 3; dot ['D'] = 2; dot ['C'] = 1; 24} 25 void process () {26 while (CIN> inputnum) {27 for (INT I = 0; I <inputnum; I ++) {28 CIN> numofcards; 29 point = 0; 30 // licensing 31 for (int K = 0; k <numofcards; k ++) {32 CIN> str1> str2; 33 ADM [k] = dot [str1] + dot [str2]; // increase the number of cards by 10 times, plus color 34} 35 for (Int J = 0; j <numofcards; j ++) {36 CIN> str1> str2; 37 Eve [J] = dot [str1] + dot [str2]; 38} 39 // 40 sort (ADM, ADM + numofcards); // sort the cards of two people in ascending order by 41 sort (Eve, Eve + numofcards); 42 for (INT I = 0, j = 0; I <numofcards & J <numofcards;) {43 If (Eve [I]> ADM [J]) {44 point ++; 45 I ++; j ++; 46} 47 else I ++; 48} // sort the cards of two people in ascending order and compare 49/* For example, ADM [3] = {1, 2, 3 }, eve [3] = {1, 2, 3}; 50 First ADM [0] = Eve [0] 51 and then compare it with ADM [0] With Eve [1, eve [1]> ADM [0]; 52 Eve [2]> ADM [1]; 53: How many times does Eve win ADM */54 cout <point <Endl; 55} 56} 57}

 

Poj 2062 card game cheater

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.