1061. Dating (20)

 1 #include <stdio.h>

 2 #include <map>

 3 #include <string.h>

 4 #include <ctype.h>

 5 using namespace std;

 6 int main()

 7 {

 8    map<char,int> ToHour;

 9    int i;

10    for(i=0;i<=9;i++)

11        ToHour['0'+i]=i;

12    for(i='A';i<='N';i++)

13        ToHour[i]=i-'A'+10;

14    

15    char Week[7][4]={ "MON", "TUE", "WED", "THU", "FRI","SAT","SUN"};

16 

17    char line1[61],line2[61],line3[61],line4[61];

18 

19    while(gets(line1)!=NULL)

20    {

21        gets(line2);

22        gets(line3);

23        gets(line4);

24        int fir=1;

25        for(i=0;i<(strlen(line1)<strlen(line2)?strlen(line1):strlen(line2));i++)

26        {

27            if(line1[i]==line2[i]&&line1[i]>='A'&&line1[i]<='G')

28            {

29                   printf("%s",Week[line1[i]-'A']);

30                   break;   

31            }

32        }

33 

34        for(++i;i<(strlen(line1)<strlen(line2)?strlen(line1):strlen(line2));i++)

35        {

36            if(line1[i]==line2[i]&&((line1[i]>='A'&&line1[i]<='N')||(line1[i]>='0'&&line1[i]<='9')))

37            {

38                       printf(" %02d",ToHour[line1[i]]);

39                        break;  

40            }

41        }

42 

43         for(i=0;i<(strlen(line3)<strlen(line4)?strlen(line3):strlen(line4));i++)

44         {

45             if(line3[i]==line4[i]&&isalpha(line3[i]))

46             {

47                 printf(":%02d\n",i);

48                 break;

49             }

50         }

51    }

52    

53 }

 

你可能感兴趣的:(in)