zoukankan      html  css  js  c++  java
  • 纸牌游戏

    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  
  • 相关阅读:
    [Cogs727] [网络流24题#2] 太空飞行计划 [网络流,最小割]
    [Cogs14] [网络流24题#1] 飞行员分配方案 [网络流,最大流,二分图匹配]
    [Poj2112][USACO2003 US OPEN] Optimal Milking [网络流,最大流][Dinic+当前弧优化]
    基本高精度模板
    Dinic模板
    [poj1698]Alice's Chance[网络流]
    [cf 599D] Spongebob and Squares
    [cf 599C] Day at the Beach
    [BZOJ1004]Cards
    [BZOJ1007]水平可见直线
  • 原文地址:https://www.cnblogs.com/wangmengmeng/p/5510116.html
Copyright © 2011-2022 走看看