HDU6308-2018ACM暑假多校联合训练1011-Time Zone

题目大意就是给你UTC-8时区的时间 让你求对应时区的时间
哇 这个题 看似简单,但是一开始怎么都过不了啊
同学用自己写的read过了,后来看了一下各位大佬说改成分钟随便过,就随便过了
Problem Description
Chiaki often participates in international competitive programming contests. The time zone becomes a big problem.
Given a time in Beijing time (UTC +8), Chiaki would like to know the time in another time zone s.
 
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:
The first line contains two integers a, b (0≤a≤23,0≤b≤59) and a string s in the format of "UTC+X'', "UTC-X'', "UTC+X.Y'', or "UTC-X.Y'' (0≤X,X.Y≤14,0≤Y≤9).
 
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
#include <cstdio>
#include <iostream> using namespace std; int main()
{
int t;
scanf("%d", &t); while (t--)
{
int p, q;
float f=0.0;
char s[];
char s1[];
scanf("%d %d %s", &p, &q, s);
sscanf(s + ,"%f",&f);
f += 0.01;
if (s[] == '-')
f = -f;
int num = p * + q - * ;
p = f * 60.0;
num += p;
if (num < )
num += ;
else if (num >= )
num -= ; p = num / ;
q = num - p * ;
printf("%02d:%02d\n", p, q);
} return ;
}
上一篇:HDU6330-2018ACM暑假多校联合训练Problem L. Visual Cube


下一篇:HDU6301-2018ACM暑假多校联合训练1004-Distinct Values