HDU 5099 - Comparison of Android versions
2015-07-27 10:51
274 查看
Problem Description
As an Android developer, itˇs really not easy to figure out a newer version of twokernels, 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. Thecode names are ordered alphabetically. The latest code name is K (KitKat).
The second letter is a branch code that allows Google to identify the exactcode branch that the build was made from, and R is by convention the primaryrelease 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 withinthe quarter, so F85 is June 24 2010.
Finally, the last letter identifies individual versions related to the samedate code, sequentially starting with A; A is actually implicit and usuallyomitted 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 linestarting with ¨Case #: 〃 (# means the number of the test case). Then, output the result ofrelease comparison as follows:
● Print "<" if the release of the firstbuild number is lower than the second one;
● Print "=" if the release of the first buildnumber is same as he second one;
● Print ">" if the release of the firstbuild number is higher than the second one.
Continue to output the result of date comparison as follows:
● Print "<" if the date of the first buildnumber is lower than the second one;
● Print "=" if the date of the first buildnumber is same as he second one;
● Print ">" if the date of the first buildnumber is higher than the second one.
If two builds are not in the same code branch, just compare the date code; ifthey are in the same code branch, compare the date code together with theindividual version.
Sample Input
2
FRF85B EPF21B
KTU84L KTU84M
Sample Output
Case 1: > >
Case 2: = <
思路:
模拟
As an Android developer, itˇs really not easy to figure out a newer version of twokernels, 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. Thecode names are ordered alphabetically. The latest code name is K (KitKat).
The second letter is a branch code that allows Google to identify the exactcode branch that the build was made from, and R is by convention the primaryrelease 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 withinthe quarter, so F85 is June 24 2010.
Finally, the last letter identifies individual versions related to the samedate code, sequentially starting with A; A is actually implicit and usuallyomitted 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 linestarting with ¨Case #: 〃 (# means the number of the test case). Then, output the result ofrelease comparison as follows:
● Print "<" if the release of the firstbuild number is lower than the second one;
● Print "=" if the release of the first buildnumber is same as he second one;
● Print ">" if the release of the firstbuild number is higher than the second one.
Continue to output the result of date comparison as follows:
● Print "<" if the date of the first buildnumber is lower than the second one;
● Print "=" if the date of the first buildnumber is same as he second one;
● Print ">" if the date of the first buildnumber is higher than the second one.
If two builds are not in the same code branch, just compare the date code; ifthey are in the same code branch, compare the date code together with theindividual version.
Sample Input
2
FRF85B EPF21B
KTU84L KTU84M
Sample Output
Case 1: > >
Case 2: = <
思路:
模拟
代码: #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; int main() { int n, k = 1; scanf("%d", &n); while (n--) { char st1[10], st2[10]; scanf("%s%s", st1, st2); int len = 6; printf("Case %d: ", k++); if (st1[0]<st2[0]) printf("< "); else if (st1[0] == st2[0]) printf("= "); else printf("> "); bool flag = false; if (st1[1] == st2[1]) flag = true; if (st1[2]>st2[2]) printf(">\n"); else if (st1[2]<st2[2]) printf("<\n"); else { int a, b; a = b = 0; a = (st1[3] - '0') * 10 + st1[4] - '0'; b = (st2[3] - '0') * 10 + st2[4] - '0'; if (a>b) printf(">\n"); else if (a<b) printf("<\n"); else { if (flag == false) printf("=\n"); else { if (st1[5]<st2[5]) printf("<\n"); else if (st1[5]>st2[5]) printf(">\n"); else printf("=\n"); } } } } return 0; }
相关文章推荐
- Android中管理多个Fragment的最佳实践,完美解决保存状态与重影问题
- Android电池驱动(三)(自用)
- Android 异步消息处理机制 让你深入理解 Looper、Handler、Message三者关系
- Android Studio多渠道打包
- Android 自定义Dialog去除title导航栏
- 7种形式的Android Dialog使用举例
- android-percent-support-extend根据百分比高效自动适配页面库。
- Android Studio 开发利器【常用插件】
- Android Service的简介(自用)
- Android(java)学习笔记131:Intent启动别的Activity
- android jni
- android APK反编译及代码混淆
- android jni
- Android跟踪NDK崩溃信息
- android 解析xml
- Android高效加载大图、多图解决方案,有效避免程序OOM
- 【进阶android】Volley源码分析——总述
- Android 快速开发系列 打造万能的ListView GridView 适配器
- Android完全退出应用程序的方法
- Android休眠唤醒实例(自用)