• 纸牌游戏


    Time Limit: 1000ms
    Memory Limit: 128000KB
    64-bit integer IO format:      Java class name:
    • 玩家1和玩家2各出一张牌,看谁大。如果两张牌都不是王牌花色或则都是王牌花色,则牌面大的牌大,如果牌面一样大则一样大。若其中一张牌是王牌而另一张不是,则无论牌面如何都是王牌花色大。

     

    Input

    第一行一个数字n,代表数据组数(n <= 10)
    对于每组数据,首先输入一个字符(SHDC),表示王牌花色。
    接下去一行有两张牌面,表示为牌面花色,如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
    ",x[a-1],y[b-1]);
    55         //printf("%d %d
    ",i,j);
    56 
    57         if(x[a-1]==m&&y[b-1]!=m)
    58             printf("YES
    ");
    59         else if(x[a-1]!=m&&y[b-1]==m)
    60             printf("NO
    ");
    61         else if(i>j)
    62             printf("YES
    ");
    63         else
    64             printf("NO
    ");
    65     }
    66 }
    67  
  • 相关阅读:
    Qt之QFileSystemWatcher
    office2007-安装程序找不到office.zh-cn*.文件
    Maven父子项目配置-多模块(multi-modules)结构
    Maven项目打包,Jar包不更新的问题
    开发Spring Shell应用程序
    Spring Shell参考文档
    Spring Shell介绍
    maven项目打包时生成dependency-reduced-pom.xml
    使用VBA批量转换Excel格式,由.xls转换成.xlsx
    修改MyEclipse取消默认工作空间
  • 原文地址:https://www.cnblogs.com/wangmengmeng/p/5510116.html
Copyright © 2020-2023  润新知