点击链接PAT甲级-AC全解汇总
题目:
这道题和乙级1014一模一样,直接上链接:
PAT乙级-1014 福尔摩斯的约会 (20分)
我的代码:
#include<bits/stdc++.h>
using namespace std;int main()
{
char a1[60],a2[60],a3[60],a4[60];cin>>a1>>a2>>a3>>a4;int day=0,hh=0,mm=0;int b=0;int len=strlen(a1)<strlen(a2)?strlen(a1):strlen(a2);for(int i=0;i<len;i++){
if(a1[i]==a2[i]&&b==0&&a1[i]>='A'&&a1[i]<='G'){
day=a1[i]-'A'+1;b=1;}else if(a1[i]==a2[i]&&b==1){
if(a1[i]>='A'&&a1[i]<='N'){
hh=a1[i]-'A'+10;break;}if(a1[i]>='0'&&a1[i]<='9'){
hh=a1[i]-'0';break;}}}len=strlen(a3)<strlen(a4)?strlen(a3):strlen(a4);for(int i=0;i<len;i++){
if(a3[i]==a4[i]&&((a3[i]>='A'&&a3[i]<='Z')||(a3[i]>='a'&&a3[i]<='z'))){
mm=i;break;}}switch(day){
case 1:cout<<"MON ";break;case 2:cout<<"TUE ";break;case 3:cout<<"WED ";break;case 4:cout<<"THU ";break;case 5:cout<<"FRI ";break;case 6:cout<<"SAT ";break;case 7:cout<<"SUN ";break;}printf("%02d:%02d",hh,mm);return 0;
}