天天看點

Comparison of Android versions(strcmp的應用)

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

題目意思:這是一個安卓版本代碼的比較,這裡每組資料有兩個代碼代表不同的安卓版本分别得出版本的大小和日期的大小。版本代碼中第一個字母代表着大版本,第二個字母代表分支版本,第三四五代表着日期,最後一個字母代表與日期相關的單個版本。題目要求是,先比較大版本,之後比較日期。如果分支版本相同,那麼既要比較日期還要比較和日期相關的單個版本,如果分支版本不同,那麼隻需比較日期即可。

解題思路:前兩天我還剛剛給我的大魅族更新到了安卓8.0,另一台華為也更新到了8.0,都徹底吃上了奧利奧。這個題對于不了解安卓版本的人來說看起來确實吃點力,實際上這個問題化簡來看就可以看成:

1、比較兩個字元串的第一個字母的大小;

2、如果兩個字元串的第二個字母不同就比較接下來的三個字母的大小,如果第二個字母相同就比較剩餘的四個字母!

 就是strcmp的應用