2018杭电多校day1_K Time Zone HDU - 6308

这是一道关于时区转换的模拟题,题目描述Chiaki在国际编程竞赛中遇到时区问题。需要将北京时间(UTC +8)转换为其他指定时区的时间,输入包括小时和分钟以及目标时区信息,输出转换后的24小时制时间。
摘要由CSDN通过智能技术生成

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 ss. 

Input

There are multiple test cases. The first line of input contains an integer TT (1≤T≤1061≤T≤106), indicating the number of test cases. For each test case: 
The first line contains two integers aa, bb (0≤a≤23,0≤b≤590≤a≤23,0≤b≤59) and a string ss in the format of "UTC+X'', "UTC-X'', "UTC+X.Y'', or "UTC-X.Y'' (0≤X,X.Y≤14,0≤Y≤90≤X,X.Y≤14,0≤Y≤9).

Output

For each test, output the time in the format of hh:mmhh: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<bits/stdc++.h>

#define ms(a,x) memset(a,x,sizeof(a))
using namespace std;

#define N 200
#define MAX 2000000

typedef long long ll;
//
int main(){
	int t;
	int n,m;
	float x;
	scanf("%d",&t);
	while(t--){
		scanf("%d%d UTC%f",&n,&m,&x);
		int z=(int)(x*10)%10;
		 
		m+=z*6;
		if(m>=60){	n++;m-=60; }
		if(m<0){	n--;m+=60;}
		n+=(int)x-8;
		if(n>=24)n-=24;
		else if(n<0)n+=24;
		
		printf("%02d:%02d\n",n,m);	
	}
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值