Time Limit: 1000ms
Memory Limit: 128000KB
64-bit integer IO format: Java class name:
Submit Status
- 玩家1和玩家2各出一張牌,看誰大。如果兩張牌都不是王牌花色或則都是王牌花色,則牌面大的牌大,如果牌面一樣大則一樣大。若其中一張牌是王牌而另一張不是,則無論牌面如何都是王牌花色大。
Input
第一行一個數字n,代表資料組數(n <= 10)
對于每組資料,首先輸入一個字元(S\H\D\C),表示王牌花色。
接下去一行有兩張牌面,表示為牌面花色,如8D、9S等。
Output
對于每組資料,輸出第一張牌是否比第二張牌大,若是則輸出YES,否則輸出NO
Sample Input
1
H
QH 9S
Sample Output
YES
Hint
A的值為1,不是13
可惡的字元串處理...
代碼:
1 #include <stdio.h>
2 #include <string.h>
3 #include <math.h>
4 #include <limits.h>
5 #include <algorithm>
6 #include <iostream>
7 #include <ctype.h>
8 #include <iomanip>
9 #include <queue>
10 #include <map>
11 #include <stdlib.h>
12 using namespace std;
13
14 int main()
15 {
16 int n,i,j;
17 char m;
18 char x[22],y[22];
19 scanf("%d",&n);
20 while(n--){
21 getchar();
22 scanf("%c",&m);
23 scanf("%s%s",x,y);
24
25 int a=strlen(x);
26 int b=strlen(y);
27
28 if(x[0]=='1')
29 i=10;
30 else if(x[0]=='A')
31 i=1;
32 else if(x[0]=='J')
33 i=11;
34 else if(x[0]=='Q')
35 i=12;
36 else if(x[0]=='K')
37 i=13;
38 else
39 i=x[0]-'0';
40
41 if(y[0]=='1')
42 j=10;
43 else if(y[0]=='A')
44 j=1;
45 else if(y[0]=='J')
46 j=11;
47 else if(y[0]=='Q')
48 j=12;
49 else if(y[0]=='K')
50 j=13;
51 else
52 j=y[0]-'0';
53
54 //printf("%c %c\n",x[a-1],y[b-1]);
55 //printf("%d %d\n",i,j);
56
57 if(x[a-1]==m&&y[b-1]!=m)
58 printf("YES\n");
59 else if(x[a-1]!=m&&y[b-1]==m)
60 printf("NO\n");
61 else if(i>j)
62 printf("YES\n");
63 else
64 printf("NO\n");
65 }
66 }
67