java题解
考察字符串基础,主要是逻辑表达式也要合理。时间不够,就多用空间换。
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
String str1=sc.nextLine(),str2=sc.nextLine(),str3=sc.nextLine(),str4=sc.nextLine();
int l1=str1.length() ,l2=str2.length(),l3=str3.length() ,l4=str4.length();
int L1=l1>=l2?l2:l1,L3=l3>=l4?l4:l3;
String[] day={"MON","TUE","WED","THU","FRI","SAT","SUN"};
int f=0;
for (int i = 0; i <L1 ; i++) {
if (str1.charAt(i)==str2.charAt(i)&&str1.charAt(i)>='A'&&str1.charAt(i)<='G') {
f=i;
System.out.print(day[str1.charAt(i)-'A']+" ");
break;
}
}
for (int i = f+1; i <L1 ; i++) {
if (str1.charAt(i)==str2.charAt(i)&&str1.charAt(i)>='A'&&str1.charAt(i)<='N') {
System.out.print((str1.charAt(i)-'A')+10);
break;
}
if (str1.charAt(i)==str2.charAt(i)&&str1.charAt(i)>='0'&&str1.charAt(i)<='9') {
System.out.print("0"+str1.charAt(i));
break;
}
}
for (int i = 0; i <L3 ; i++) {
if (str3.charAt(i)==str4.charAt(i)&&((str3.charAt(i)>='a'&&str3.charAt(i)<='z')||(str3.charAt(i)>='A'&&str3.charAt(i)<='Z'))){
if (i<10) System.out.print(":0"+i);
else System.out.print(":"+i);
break;
}
}
}
}