您的位置:首页 > 其它

纸牌游戏

2016-05-19 20:52 288 查看
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

Submit Status

可恶的字符串处理...

代码:

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#include <algorithm>
#include <iostream>
#include <ctype.h>
#include <iomanip>
#include <queue>
#include <map>
#include <stdlib.h>
using namespace std;

int main()
{
int n,i,j;
char m;
char x[22],y[22];
scanf("%d",&n);
while(n--){
getchar();
scanf("%c",&m);
scanf("%s%s",x,y);

int a=strlen(x);
int b=strlen(y);

if(x[0]=='1')
i=10;
else if(x[0]=='A')
i=1;
else if(x[0]=='J')
i=11;
else if(x[0]=='Q')
i=12;
else if(x[0]=='K')
i=13;
else
i=x[0]-'0';

if(y[0]=='1')
j=10;
else if(y[0]=='A')
j=1;
else if(y[0]=='J')
j=11;
else if(y[0]=='Q')
j=12;
else if(y[0]=='K')
j=13;
else
j=y[0]-'0';

//printf("%c %c\n",x[a-1],y[b-1]);
//printf("%d %d\n",i,j);

if(x[a-1]==m&&y[b-1]!=m)
printf("YES\n");
else if(x[a-1]!=m&&y[b-1]==m)
printf("NO\n");
else if(i>j)
printf("YES\n");
else
printf("NO\n");
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: