HDU 5099 Comparison of Android versions(字符串)
来源:互联网 发布:淘宝让你提供质检报告 编辑:程序博客网 时间:2024/06/05 05:58
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5099
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.
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.
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.
● 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
2FRF85B EPF21BKTU84L KTU84M
Sample Output
Case 1: > >Case 2: = <
Source
2014上海全国邀请赛——题目重现(感谢上海大学提供题目)
Recommend
hujie | We have carefully selected several similar problems for you: 5098 5097 5096 5095 5094
PS:
1、比较两个字符串的第一个字母的大小;
2、如果两个字符串的第二个字母不同就比较接下来的三个字母的大小,
如果第二个字母相同就比较剩余的四个字母!
代码如下:
#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] = '\0'; bb[0] = b[2]; bb[1] = b[3]; bb[2] = b[4]; bb[3] = b[5]; bb[4] = '\0'; 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] = '\0'; //aa[3] = a[5]; bb[0] = b[2]; bb[1] = b[3]; bb[2] = b[4]; bb[3] = '\0'; //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;}
1 0
- HDU 5099 Comparison of Android versions(字符串)
- HDU 5099 Comparison of Android versions【字符串+模拟】
- 【瞎搞】 HDU 5099 Comparison of Android versions
- hdu 5099 Comparison of Android versions(水题)
- HDU 5099 Comparison of Android versions
- HDU 5099 - Comparison of Android versions
- hdu 5099 Comparison of Android versions
- HDOJ 5099 Comparison of Android versions(字符串模拟)
- HDU 5099 Comparison of Android versions(模拟-水题)
- HDU 5099 Comparison of Android versions(模拟)
- HDU 5099 Comparison of Android versions(坑水题)
- Comparison of Android versions
- HDU 5099 Comparison of Android versions(上海邀请赛模拟水题)
- HDOJ 5099 Comparison of Android versions 坑题
- hdoj-5099-Comparison of Android versions
- hdoj.5099 Comparison of Android versions【字符串处理,水题】 2015/08/13
- Comparison of Android versions(2014上海全国邀请赛)
- hdu 5199 Comparison of Android version
- 关于技术学习的一点思考
- 排序字符串的前缀压缩算法,结合lucene
- HDU1518 Square 【剪枝】
- hdu 5093 Battle ships(最大流)
- 栈和队列
- HDU 5099 Comparison of Android versions(字符串)
- [LeetCode OJ]Populating Next Right Pointers in Each Node
- Android项目-高考作文功能简介(一)
- hdu 5090 Game with Pearls (二分匹配)
- MDCC 2014移动开发者大会 参展商活动的小礼品
- GitHub“最受欢迎的开源项目” TOP 50 android开源项目 直接拿来用
- python如何安装pip和easy_installer工具
- 寻路算法 A* (一)
- 去爬山恐感被体的干撒