A. card game

Source: Internet
Author: User
Time limit per test

2 seconds

Memory limit per test

256 megabytes

Input

Standard Input

Output

Standard output

There is a card game called "durak", which means "fool" in Russian. the game is quite popular in the countries that used to form USSR. the problem does not state all the game's rules explicitly-you can find them later yourselves if you want.

To play durak you need a pack of 36 cards. Each card has a suit ("S ",
"H", "D" and "C ")
And a rank (in the increasing order "6", "7 ",
"8", "9", "T ",
"J", "Q", "K"
And "A"). At the beginning of the game one suit is arbitrarily chosen as trump.

The players move like that: one player puts one or several of his cards on the table and the other one shoshould beat each of them with his cards.

A card beats another one if both cards have similar suits and the first card has a higher rank then the second one. besides, a trump card can beat any non-trump card whatever the cards 'ranks are. in all other cases you can not beat the second card with
First one.

You are given the trump suit and two different cards. Determine whether the first one beats the second one or not.

Input

The first line contains the tramp suit. It is "S", "H ",
"D" or "C ".

The second line contains the description of the two different cards. Each card is described by one word consisting of two symbols. The first symbol stands for the rank ("6 ",
"7", "8", "9 ",
"T", "J", "Q ",
"K" and "A"), and the second
One stands for the suit ("S", "H ",
"D" and "C ").

Output

Print "yes" (without the quotes) if the first cards beats the second one. Otherwise, print "no"
(Also without the quotes ).

Sample test (s) Input
HQH 9S
Output
YES
Input
S8D 6D
Output
YES
Input
C7H AS
Output
NO

Problem description: This is just a string.

#include<iostream>#include<map>#include<string>#include<algorithm>using namespace std;int main(){string s1, s2,s;int i,pos1,pos2;char a[10]="6789TJQKA";cin>>s;cin >> s1 >> s2;if(s1[1]==s[0]){if(s2[1]!=s[0]){cout<<"YES"<<endl;}else{for(i=0;i<9;i++){if(s1[0]==a[i]){pos1=i;}if(s2[0]==a[i]){pos2=i;}}if(pos1<=pos2){cout<<"NO"<<endl;}else{cout<<"YES"<<endl;}}}else {if(s1[1]==s2[1]){for(i=0;i<9;i++){if(s1[0]==a[i]){pos1=i;}if(s2[0]==a[i]){pos2=i;}}if(pos1<=pos2){cout<<"NO"<<endl;}else{cout<<"YES"<<endl;}}else{cout<<"NO"<<endl;}}return 0;}

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.