题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5099
简单字符串比较 然而我wa了一发,因为我没输出Case。。。掀桌!!!
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char s1[10];
char s2[10];
int cmp1(){//2 3 4 5
for(int i = 2;i <= 5;i++){
if(s1[i] > s2[i]){
printf(">\n");
return 1;
}
if(s1[i] < s2[i]){
printf("<\n");
return -1;
}
}
printf("=\n");
return 0;
}
int cmp2(){//2 3 4
for(int i = 2;i <= 4;i++){
if(s1[i] > s2[i]){
printf(">\n");
return 1;
}
if(s1[i] < s2[i]){
printf("<\n");
return -1;
}
}
printf("=\n");
return 0;
}
int main(){
int T;
scanf("%d",&T);
int casee = 0;
while(T--){
casee++;
scanf("%s%s",s1,s2);printf("Case %d: ",casee);
if(s1[0] == s2[0])
printf("= ");
else if(s1[0] > s2[0])
printf("> ");
else
printf("< ");
if(s1[1] == s2[1]){
cmp1();
}
else{
cmp2();
}
}
return 0;
}