HDU 5099 Comparison of Android versions (string)

Source: Internet
Author: User
Tags strcmp

Title Link: http://acm.hdu.edu.cn/showproblem.php?pid=5099


Problem Descriptionas an Android developer, Itˇs really isn't easy-to-figure out a newer version of the kernels, because and Roid are updated so frequently and have 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 is ordered alphabetically. The latest code name is K (KitKat).
The second letter are a branch code that allows Google to identify the exact code branch that the build were made from, and R is by convention the primary release branch.

The next letter and the digits is a date code. The letter counts quarters, with A being Q1 2009. Therefore, F is Q2 2010. The 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 compare the Android build numbers.
Inputthe first line is a integer n (1 <= n <=), which indicates how many test cases need to process.

Each of the test case consists of a is a single line containing the build numbers, separated by a space character.
Outputfor each test case, output A, starting with¨case #:〃 (# means the number of the 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 the builds is not in the same Code branch, just compare the date code; If they is in the same Code branch, compare the date code together with the individual version.
Sample Input
2frf85b epf21bktu84l ktu84m

Sample Output
Case 1: > >case 2: = <

SOURCE2014 Shanghai National Invitational Competition--re-title (thanks to Shanghai University for its topics)
Recommendhujie | We have carefully selected several similar problems for you:5098 5097 5096 5095 5094

Ps:

1. Compare the size of the first letter of the two string;

2. If the second letter of the two string is different, compare the next three letters to the size,

If the second letter is the same, compare the remaining four letters!


The code is as follows:

#include <cstdio> #include <cstring>const int maxn = 17;int Main () {int t;    Char A[MAXN], B[MAXN];    Char AA[MAXN], BB[MAXN];    int cas = 0;    scanf ("%d", &t);    GetChar ();        while (t--) {scanf ("%s", a);        scanf ("%s", b);        printf ("Case%d:", ++cas);        if (A[0] > B[0]) {printf (">");        } else if (a[0] = = B[0]) {printf ("=");        } else if (A[0] < b[0]) {printf ("<");            } if (a[1] = = B[1]) {aa[0] = a[2];            AA[1] = a[3];            AA[2] = a[4];            AA[3] = a[5];            AA[4] = ' + ';            Bb[0] = b[2];            BB[1] = b[3];            BB[2] = b[4];            BB[3] = b[5];            BB[4] = ' + ';            if (strcmp (AA,BB) < 0) {printf ("<");            } else if (strcmp (aa,bb) = = 0) {printf ("="); } else IF (strcmp (AA,BB) > 0) {printf (">");            }} else {aa[0] = a[2];            AA[1] = a[3];            AA[2] = a[4];            AA[3] = ' + ';            AA[3] = a[5];            Bb[0] = b[2];            BB[1] = b[3];            BB[2] = b[4];            BB[3] = ' + ';            BB[3] = b[5];            if (strcmp (AA,BB) < 0) {printf ("<");            } else if (strcmp (aa,bb) = = 0) {printf ("=");            } else if (strcmp (AA,BB) > 0) {printf (">");    }} printf ("\ n"); } return 0;}


HDU 5099 Comparison of Android versions (string)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.