Problem Description Chiaki often participates in international competitive programming contests. The time zone becomes a big problem.
Input There are multiple test cases. The first line of input contains an integer T (1≤T≤106 ), indicating the number of test cases. For each test case:
Output
For each test, output the time in the format of hh:mm (24-hour clock).
Sample Input
3 11 11 UTC+8 11 12 UTC+9 11 23 UTC+0
Sample Output
11:11 12:12 03:23 |
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6308
题意:北京标准时间是UTC+8,现在给出标准的北京时间和别的地方的时区,要求别的地方的当前时间
AC代码
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
int a,b,c,d,e,s,w;
char m[20];
while(~scanf("%d",&a))
{
while(a--)
{
s=0;w=0;
scanf("%d %d %s",&b,&c,&m);
d=strlen(m);
if(d==5)
{
s=m[4]-'0';
}
else if(d==6)
{
s=(m[4]-'0')*10+m[5]-'0';
}
else if(d==7)
{
s=m[4]-'0';
w=m[6]-'0';
}
else if(d==8)
{
s=(m[4]-'0')*10+m[5]-'0';
w=m[7]-'0';
}
if(m[3]=='-')
{
b=b-8-s;
e=w*6;
if(e<=c)
c=c-e;
else
{
b--;
c=60+c-e;
}
}
else
{
b=b-(8-s);
e=w*6;
if(e+c<60)
c=c+e;
else
{
b++;
c=c+e-60;
}
}
if(b>=24)
b=b-24;
else if(b<0)
b=b+24;
printf("%02d:%02d\n",b,c);
}
}
return 0;
}