Description
有一种特殊的日历法,它的一天和我们现在用的日历法的一天是一样长的。它每天有10个小时,每个小时有100分钟,每分钟有100秒。10天算一周,10周算一个月,10个月算一年。现在要你编写一个程序,将我们常用的日历法的日期转换成这种特殊的日历表示法。这种日历法的时、分、秒是从0开始计数的。日、月从1开始计数,年从0开始计数。秒数为整数。假设 0:0:0 1.1.2000 等同于特殊日历法的 0:0:0 1.1.0。
Input
第一行是一个正整数 N ,表明下面有 N 组输入。每组输入有一行,格式如下:hour:minute:second day.month.year
表示常规的日期。日期总是合法的。2000 <= year <= 50000。
Output
每组输入要求输出一行。格式如下:mhour:mmin:msec mday.mmonth.myear 是输入日期的特殊日历表示方法。
Sample Input
7
0:0:0 1.1.2000
10:10:10 1.3.2001
0:12:13 1.3.2400
23:59:59 31.12.2001
0:0:1 20.7.7478
0:20:20 21.7.7478
15:54:44 2.10.20749
Sample Output
0:0:0 1.1.0
4:23:72 26.5.0
0:8:48 58.2.146
9:99:98 31.8.0
0:0:1 100.10.2000
0:14:12 1.1.2001
6:63:0 7.3.6848
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int run(int y)
{
if((y%4==0 && y%100!=0) || y%400==0)
return 29;
else
return 28;
}
int main()
{
int month[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int n;
cin>>n;
for(int k=1;k<=n;k++)
{
int h,m,s,day,mon,year;
char c;
cin>>h>>c>>m>>c>>s>>day>>c>>mon>>c>>year;//输入是这些数据,输出也是这些数据只是重新就算数据
int day0=0,year0,i;
for( i=2000;i<=year-1;i++)
{
year0=365+run(i)-28; //year有365或者366天
day0+=year0; //day就是把之前的天数的和加在一块
}
month[2]=run(year); //二月根据是否闰年,需要另外计算
for( i=1;i<=mon-1;i++)
day0+=month[i]; //day加完“整数”,再加月的余数。
day0+=day-1; //再加日的余数。
year=day0/1000;day0=day0%1000;
mon=day0/100;day0=day0%100;
day=day0;
mon++;day++;//++是因为数据从1开始,而计算中从零开始计算的
int sec=0;
sec=h*3600+m*60+s;sec=sec/0.864;
h=sec/10000;sec=sec%10000;
m=sec/100;sec=sec%100;
s=sec;
cout<<h<<":"<<m<<":"<<s<<" "<<day<<"."<<mon<<"."<<year<<endl;
}
return 0;
}