HDOJ 5099 Comparison of Android versions(字符串模拟)

Comparison of Android versions

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1189    Accepted Submission(s): 478


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.
 

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: = < 其实一开始让我做这题,我是拒绝的,因为我看不懂....(衰,看了老一会 ,看出来第一个字母是人名,第二个字母是地点,第三到第五个字母是时间, 最后一个字母不知道什么意思(衰..... 然后谷歌翻译如下: 作为一名Android开发者还真不容易搞清楚两个内核的更新版本由于Android是如此频繁地更新,许多分支幸运的是谷歌识别个人用短构建代码,例如建立FRF85B 第一封信是发行代码名称F是升级Froyo代码名称字母顺序排列。最新的代号为K(奇巧 第二个字母是分支代码,使谷歌,以确定构建取得确切的代码分支R是约定主释放分支。 下一个字母两位数字的日期代码。信中计数季度A为2009年第一季度。因此F是2010年第二季度两位数 季度天,所以F852010年6月24日 最后最后的字母标识与同一日期代码各个版本依次以A开头的; A实际上隐含的,通常不再赘述 开发一个程序来比较两款Android版本号 ac代码:
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#define MAXN 10010
#define INF 0xfffffff
#define max(a,b) a>b?a:b
#define min(a,b) a>b?b:a
using namespace std;
int main()
{
	int t,i;
	char s1[8],s2[8];
	char q1,q2;
	int cas=0;
	scanf("%d",&t);
	while(t--)
	{
		scanf("%s%s",s1,s2);
		int len1=strlen(s1);
		int len2=strlen(s2);
		if(len1<6)//这里刚开始没有判断,忽略了那句话,A是可以省略的
		s1[5]='A';
		if(len2<6)
		s2[5]='A'; 
		if(s1[0]==s2[0])
		{
			q1='=';
		}
		else
		{
			q1=s1[0]>s2[0]?'>':'<';
		}
		int bz=0;
		for(i=2;i<=4;i++)//先比较生产日期,再看地点
		{
			if(s1[i]!=s2[i])
			{
				q2=s1[i]>s2[i]?'>':'<';
				bz=1;
				break;//没有break,wrong
			}
		}
		if(bz==0)
		{
			q2='=';
			if(s1[1]==s2[1])//生产日期相同且生产地相同,再看最后
			{
				if(s1[5]==s2[5])
				{
					q2='=';
				}
				else
				{
					q2=s1[5]>s2[5]?'>':'<';
				}
			}
		}
		printf("Case %d: %c %c\n",++cas,q1,q2);
	}
	return 0;
} 


你可能感兴趣的:(HDOJ 5099 Comparison of Android versions(字符串模拟))