zoukankan      html  css  js  c++  java
  • AOJ 491.扑克牌

    Time Limit: 1000 ms   Case Time Limit: 1000 ms   Memory Limit: 64 MB
    Total Submission: 54   Submission Accepted: 24
     
    Description
    扑克牌大家非常熟悉,扑克牌从小到大的顺序为:
    3,4,5,6,7,8,9,10,J,Q,K,A,2
    我们就做个简单的事,单张扑克牌比大小,并且还没有花色区别,也没有大小王。
    Input
    第1行:一个整数T(T<=20),代表测试数据的组数。
    第2到T+1行:每行输入两个扑克牌值,也就是描述中的那13个代号,以空格分隔。输入的字母为大写字母。
    Output
    输出T行,每行为前者和后者的关系。
    前者大于后者则输出>
    前者等于后者则输出=
    前者小于后者则输出<
    Sample Input
    Original Transformed
    2
    3 3
    A K
    
    Sample Output
    Original Transformed
    =
    >

    应特别注意其中唯一一个占据两个字符空间10。

    可以通过读入字符串来读入数据,判断c[0](因为1对应的只有10,数字1用A表示)

     1 /*
     2 By:OhYee
     3 Github:OhYee
     4 Email:oyohyee@oyohyee.com
     5 */
     6 #include <cstdio>
     7 #include <algorithm>
     8 #include <cstring>
     9 #include <cmath>
    10 #include <string>
    11 #include <iostream>
    12 #include <vector>
    13 #include <list>
    14 #include <stack>
    15 using namespace std;
    16  
    17 #define REP(n) for(int o=0;o<n;o++)
    18  
    19 const char d[13] = {'3','4','5','6','7','8','9','1','J','Q','K','A','2'};
    20  
    21 int main() {
    22     int T;
    23     scanf("%d",&T);
    24     REP(T) {
    25         char a[3],b[3];
    26         scanf("
    %s%s
    ",&a,&b);
    27         if(a[0] == b[0]) {
    28             printf("=
    ");
    29             continue;
    30         }
    31         int i,j;
    32         for(i = 0;i < 13;i++)
    33             if(d[i] == a[0])
    34                 break;
    35         for(j = 0;j < 13;j++)
    36             if(d[j] == b[0])
    37                 break;
    38         printf("%c
    ",i < j ? '<' : '>');
    39     }
    40     return 0;
    41 }
  • 相关阅读:
    设计模式学习笔记之状态模式
    设计模式学习笔记之观察者模式
    设计模式学习笔记之模板方法模式
    设计模式学习笔记之策略模式
    设计模式学习笔记之装饰者模式
    Comparable和Comparator接口的比较
    Java中关键字continue、break和return的区别
    斐波那契数列-兔子问题
    用Java编程计算猴子吃桃问题
    (转载)Java多线程入门理解
  • 原文地址:https://www.cnblogs.com/ohyee/p/5269856.html
Copyright © 2011-2022 走看看