来源:http://www.patest.cn/contests/pat-b-practise/1014
#include<stdio.h>
#include<ctype.h>
int main() {
char arr1[61], arr2[61], arr3[61], arr4[61] = {0};
int i = 0, k = 0;
int time[3] = {0};
char table[7][4] = {"MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"};
scanf("%s%s%s%s", arr1, arr2, arr3, arr4);
for (i = 0; i < 60; i++) {
if (k == 0) {
if (arr1[i] == arr2[i] && arr1[i] >= 'A'
&& arr1[i] <= 'G') {
time[k] = arr1[i] - 'A';
k++;
}
} else {
if (arr1[i] == arr2[i]
&& ((arr1[i] >= 'A' && arr1[i] <= 'N')
|| (arr1[i] >= '0' && arr1[i] <= '9'))) {
if (arr1[i] >= 'A' && arr1[i] <= 'N')
time[k] = arr1[i] - 'A' + 10;
else
time[k] = arr1[i] - '0';
break;
}
}
}
for (i = 0; i < 60; i++) {
if (arr3[i] == arr4[i] && tolower(arr3[i]) >= 'a'
&& tolower(arr3[i]) <= 'z') {
time[2] = i;
break;
}
}
printf("%s ", table[time[0]]);
printf((time[1]/10)?"%d:":"0%d:", time[1]);
printf((time[2]/10)?"%d\n":"0%d\n", time[2]);
return 0;
}