题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6556
 
题意:就是一个时区转换和上下午判别。
 
解题心得:就是一个常规题,时间转换之后时钟大于等于24代表是在Tomorrow,如果小于0代表在Yesterday。只不过有一点就是半夜0点写成12点AM,这里要注意输入和输出,还有就是输出小时是%d,分钟是d。
 
 
 
#include <bits/stdc++.h>
using namespace std
;
typedef long long ll
;
map 
<string
, int> maps
;
void init() {
    string st
;
    st 
= "Beijing";
    maps
[st
] = 8;
    st 
= "Washington";
    maps
[st
] = -5;
    st 
= "London";
    maps
[st
] = 0;
    st 
= "Moscow";
    maps
[st
] = 3;
}
int main() {
    init();
    int t
; scanf("%d", &t
);
    int T 
= t
;
    while(t
--) {
        int h
, m
;
        string now
, Next
, w
;
        scanf("%d:%d", &h
, &m
);
        cin
>>w
>>now
>>Next
;
        if(w 
== "PM") {
            if(h 
!= 12)
                h 
+= 12;
        } else {
            if(h 
== 12)
                h 
-= 12;
        }
        int pos1
, pos2
;
        pos1 
= maps
[now
];
        pos2 
= maps
[Next
];
        if(pos2 
<= pos1
) {
            h 
-= (pos1 
- pos2
);
        } else {
            h 
+= (pos2 
- pos1
);
        }
        printf("Case %d: ", T
-t
);
        if(h 
< 0) {
            printf("Yesterday ");
            h 
+= 24;
        } else if(h 
>= 24) {
            printf("Tomorrow ");
            h 
-= 24;
        } else {
            printf("Today ");
        }
        string st
;
        if(h 
< 12) {
            st 
= "AM";
            if(h 
== 0) h 
+= 12;
        }
        else {
            st 
= "PM";
            if(h 
> 12)
                h 
-= 12;
        }
        printf("%d:d %s\n", h
, m
, st
.c_str());
    }
    return 0;
}