HDU 5099 Comparison of Android versions(坑水题)

C - Comparison of Android versions HDU 5099

Time Limit: 1000 MS Memory Limit: 32768 KB

64-bit integer IO format: %I64d , %I64u Java class name: Main

[Submit] [Status]

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: = <

execute time:0.001556 s, 2 db queris.


  
     规则:第一个判断号的确定是比较两个字符串的第一个字符,第二个判断号
的确定是判断两个字符串的第二个字符串,如果不相同的话只比较两个字符串的
第3到第5个字符,如果相同需要把后面的字符都比较完(字符串一共只有6个字符)

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<math.h>

using namespace std;

int n;
char str1[10],str2[10];

int main()
{
    int k = 0;
    scanf("%d",&n);
    while(n--)
    {
        k++;
        scanf("%s%s",str1,str2);
        char ch,ch2;
        if(str1[0] > str2[0])
        {
            ch = ‘>‘;
        }
        else if(str1[0] < str2[0])
        {
            ch = ‘<‘;
        }
        else
        {
            ch = ‘=‘;
        }
        if(str1[1] == str2[1])
        {
            int flag = 0;
            for(int i=2; i<=5; i++)
            {
                if(str1[i] > str2[i])
                {
                    flag = 1;
                    ch2 = ‘>‘;
                    break;
                }
                else if(str1[i] < str2[i])
                {
                    flag = 1;
                    ch2 = ‘<‘;
                    break;
                }
            }
            if(flag == 0)
            {
                ch2 = ‘=‘;
            }
        }
        else
        {
            int flag = 0;
            for(int i=2; i<=4; i++)
            {
                if(str1[i] > str2[i])
                {
                    flag = 1;
                    ch2 = ‘>‘;
                    break;
                }
                else if(str1[i] < str2[i])
                {
                    flag = 1;
                    ch2 = ‘<‘;
                    break;
                }
            }
            if(flag == 0)
            {
                ch2 = ‘=‘;
            }
        }
        printf("Case %d: %c %c\n",k,ch,ch2);
    }
    return 0;
}

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。