版本号码比较。读懂题意很简单。
1、比较两个字符串的第一个字母的大小.
2、如果两个字符串的第二个字母不同就比较接下来的三个字母的大小.
如果两个字符串的第二个字母相同就比较剩余的四个字母.
#include<iostream>
#include<string.h>
#define maxn 10010
using namespace std;
char s[maxn],ss[maxn];
int main(){
int T,times=1;
cin>>T;
getchar();
while(T--){
cin>>s>>ss;
cout<<"Case "<<times++<<':';
char tmp1[4]={0},tmp2[4]={0};
tmp1[0]=s[0];
tmp2[0]=ss[0];
//先比较首字母的大小并输出
if(strcmp(tmp1,tmp2)>0) cout<<" > ";
else if(strcmp(tmp1,tmp2)<0) cout<<" < ";
else cout<<" = ";
//再比较接下来的第二个字母
tmp1[0]=s[1];
tmp2[0]=ss[1];
//第二个字母不同,比较接下来三个字母
if(strcmp(tmp1,tmp2)!=0) {
s[5]=0;ss[5]=0;
if(strcmp(s+2,ss+2)>0)
cout<<'>'<<endl;
else if(strcmp(s+2,ss+2)<0)
cout<<'<'<<endl;
else
cout<<'='<<endl;
}
else{
if(strcmp(s+2,ss+2)>0)
cout<<'>'<<endl;
else if(strcmp(s+2,ss+2)<0)
cout<<'<'<<endl;
else
cout<<'='<<endl;
}
}
return 0;
}