zoukankan      html  css  js  c++  java
  • HDU5099——Comparison of Android versions(简单题)(2014上海邀请赛重现)

    Comparison of Android versions
    Problem Description
    As an Android developer, itˇs really not easy to figure out a newer version of two kernels, because Android is updated so frequently and has many branches. Fortunately, Google identifies individual builds with a short build code, e.g. FRF85B.
    The first letter is the code name of the release family, e.g. F is Froyo. The code names are ordered alphabetically. The latest code name is K (KitKat).
    The second letter is a branch code that allows Google to identify the exact code branch that the build was made from, and R is by convention the primary release branch.
    The next letter and two digits are a date code. The letter counts quarters, with A being Q1 2009. Therefore, F is Q2 2010. The two digits count days within the quarter, so F85 is June 24 2010.
    Finally, the last letter identifies individual versions related to the same date code, sequentially starting with A; A is actually implicit and usually omitted for brevity.
    Please develop a program to compare two Android build numbers.
    Input
    The first line is an integer n (1 <= n <= 2000), which indicates how many test cases need to process.
    Each test case consists of a single line containing two build numbers, separated by a space character.
    Output
    For each test case, output a single line starting with ¨Case #: 〃 (# means the number of the test case). Then, output the result of release comparison as follows:
    ● Print "<" if the release of the first build number is lower than the second one;
    ● Print "=" if the release of the first build number is same as he second one;
    ● Print ">" if the release of the first build number is higher than the second one.
    Continue to output the result of date comparison as follows:
    ● Print "<" if the date of the first build number is lower than the second one;
    ● Print "=" if the date of the first build number is same as he second one;
    ● Print ">" if the date of the first build number is higher than the second one.
    If two builds are not in the same code branch, just compare the date code; if they are in the same code branch, compare the date code together with the individual version.
    Sample Input
    2
    FRF85B EPF21B
    KTU84L KTU84M
    Sample Output
    Case 1: > >
    Case 2: = <

    题目大意&解题思路:

        1、比较两个字符串的第一个字母的大小.
        2、如果两个字符串的第二个字母不同就比较接下来的三个字母的大小.
              如果两个字符串的第二个字母相同就比较剩余的四个字母.

        PS:英语好读懂题就不难。TT

    Code:

     1 /*************************************************************************
     2     > File Name: shanghai_1010.cpp
     3     > Author: Enumz
     4     > Mail: 369372123@qq.com
     5     > Created Time: 2014年11月02日 星期日 13时43分08秒
     6  ************************************************************************/
     7 
     8 #include<iostream>
     9 #include<cstdio>
    10 #include<cstdlib>
    11 #include<string>
    12 #include<cstring>
    13 #include<list>
    14 #include<queue>
    15 #include<stack>
    16 #include<map>
    17 #include<set>
    18 #include<algorithm>
    19 #include<cmath>
    20 #include<bitset>
    21 #include<climits>
    22 #define MAXN 100000
    23 using namespace std;
    24 char str1[100],str2[100];
    25 int main()
    26 {
    27     int T;
    28     cin>>T;
    29     int times=1;
    30     while (T--)
    31     {
    32         cin>>str1>>str2;
    33         printf("Case %d:",times++);
    34         char tmp1[4]={0},tmp2[4]={0};
    35         tmp1[0]=str1[0];
    36         tmp2[0]=str2[0];
    37         if (strcmp(tmp1,tmp2)>0)
    38             printf(" >");
    39         else if (strcmp(tmp1,tmp2)<0)
    40             printf(" <");
    41         else printf(" =");
    42         tmp1[0]=str1[1];
    43         tmp2[0]=str2[1];
    44         if (strcmp(tmp2,tmp1)!=0)
    45         {
    46             str1[5]=0,str2[5]=0;
    47             if (strcmp(str1+2,str2+2)>0)
    48                 printf(" >
    ");
    49             else if( strcmp(str1+2,str2+2)<0)
    50                 printf(" <
    ");
    51             else
    52                 printf(" =
    ");
    53         }
    54         else
    55         {
    56             if (strcmp(str1+2,str2+2)>0)
    57                 printf(" >
    ");
    58             else if (strcmp(str1+2,str2+2)<0)
    59                 printf(" <
    ");
    60             else
    61                 printf(" =
    ");
    62         }
    63     }
    64     return 0;
    65 }
  • 相关阅读:
    4.Android开发笔记:Activity的生命周期、启动方式、最佳实践
    3.Android开发笔记:Activity 数据传递
    2.Android开发笔记:Activity
    1.《Android开发笔记》系列
    JS
    Mongodb 学习笔记简介
    Sql Server MySql 日期
    实现tomcat与IIS共用80端口
    学习Microsoft SQL Server 2008技术内幕:T-SQL语法基础--第4章
    学习Microsoft SQL Server 2008技术内幕:T-SQL语法基础
  • 原文地址:https://www.cnblogs.com/Enumz/p/4071662.html
Copyright © 2011-2022 走看看