swustoj Aconly时间戳(0275)

来源:互联网 发布:淘宝怎么提高销量2016 编辑:程序博客网 时间:2024/06/05 12:02

时间戳是自 1970年1月1日(00:00:00 GMT)以来的秒数。然而Aconly不喜欢这个东西,所以他制定了一种新的时间戳叫Aconly时间戳,它是自2009年1月1日(00:00:00 北京时间)以来的秒数。例如0 就是2009-01-01 00:00:00 , 60就是2009-01-01 00:01:00。

Description

有多组测试数据。每组数据一个整数n(0<= n <=31535999),即Aconly时间戳。

Input

输出相应的北京时间。每组数据占一行。

Output
1
2
3
4
5
0
60
10000000
31535999
Sample Input
1
2
3
4
5
2009-01-01 00:00:00
2009-01-01 00:01:00
2009-04-26 17:46:40
2009-12-31 23:59:59
/*由于题目数据只有一年,So没有判断闰年。  题目太水:( ̄▽ ̄)*/#include<iostream>#include<stdio.h>#include<algorithm>using namespace std;int main(){int n;int a[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };while (cin >> n){int y=1,t=0, s=0, f=0, m=0;//月 天 时 分 秒t = n / (60 * 60 * 24);n = n % (60 * 60 * 24);s = n / (60 * 60);n %= (60 * 60);f = n / 60;n %= 60;m = n;int sum = 0;int index = -1;for (int i = 0; i < 12; i++){sum += a[i];if (sum >= t){index = i;break;}}y = index + 1;sum -= a[index];t = t - sum + 1;cout << "2009-";//注意格式 数据只有一位时,要补0if (y <= 9){cout << "0";}cout << y << '-';if (t <= 9){cout << '0';}cout << t  << ' ';if (s <= 9){cout << '0';}cout << s << ":";if (f <= 9){cout << '0';}cout << f << ":";if (m <= 9){cout << '0';}cout << m << endl;//2009 - 01 - 01 00 : 01 : 00}return 0;}


0 0
原创粉丝点击