Description
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
Each test case consists of a single line containing two build numbers, separated by a space character.
Output
● 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
Sample Output
1、比较两个字符串的第一个字母的大小;
2、如果两个字符串的第二个字母不同就比较接下来的三个字母的大小,如果第二个字母相同就比较剩余的四个字母!
就是strcmp的应用
1 #include<stdio.h> 2 #include<string.h> 3 int main() 4 { 5 int n,i,j,k,m; 6 char s1[11],s2[11],a[11],b[11]; 7 scanf("%d",&n); 8 getchar(); 9 for(i=1; i<=n; i++)10 {11 memset(a,0,sizeof(a));12 memset(b,0,sizeof(b));13 memset(s1,0,sizeof(s1));14 memset(s2,0,sizeof(s2));15 scanf("%s %s",s1,s2);16 printf("Case %d: ",i);17 if(s1[0]==s2[0])18 {19 printf("= ");20 }21 else if(s1[0]>s2[0])22 {23 printf("> ");24 }25 else if(s1[0]<s2[0])26 {27 printf("< ");28 }29 k=0;30 m=0;31 if(s1[1]==s2[1])32 {33 for(j=2; j<=5; j++)34 {35 a[k++]=s1[j];36 b[m++]=s2[j];37 a[k]=‘\0‘;38 b[m]=‘\0‘;39 }40 }41 else42 {43 for(j=2; j<=4; j++)44 {45 a[k++]=s1[j];46 b[m++]=s2[j];47 a[k]=‘\0‘;48 b[m]=‘\0‘;49 }50 }51 if(strcmp(a,b)==0)52 printf("=");53 else if(strcmp(a,b)<0)54 {55 printf("<");56 }57 else if(strcmp(a,b)>0)58 {59 printf(">");60 }61 printf("\n");62 }63 return 0;64 }