-
总时间限制:
- 1000ms 内存限制:
- 65536kB
-
描述
- 有一种特殊的日历法,它的一天和我们现在用的日历法的一天是一样长的。它每天有10个小时,每个小时有100分钟,每分钟有100秒。10天算一周,10周算一个月,10个月算一年。现在要你编写一个程序,将我们常用的日历法的日期转换成这种特殊的日历表示法。这种日历法的时、分、秒是从0开始计数的。日、月从1开始计数,年从0开始计数。秒数为整数。假设 0:0:0 1.1.2000 等同于特殊日历法的 0:0:0 1.1.0。 输入
-
第一行是一个正整数 N ,表明下面有 N 组输入。每组输入有一行,格式如下:hour:minute:second day.month.year
表示常规的日期。日期总是合法的。2000 <= year <= 50000。
输出
- 每组输入要求输出一行。格式如下:mhour:mmin:msec mday.mmonth.myear 是输入日期的特殊日历表示方法。 样例输入
-
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
样例输出
-
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 <stdio.h>
#include <stdlib.h>
int isRunYear(int year) //判断年是不是闰年
{
if((year%4==0&&year%100!=0)||year%400==0)
return 1;
else
return 0;
}
int main()
{
int hour,minute,second,day,month,year;
int mhour,mmin,msec,mday,mmonth,myear;
int dayofmonth[2][13]={{0,31,28,31,30,31,30,31,31,30,31,30},{0,31,29,31,30,31,30,31,31,30,31,30}}; //通过二维数组的方式存储月的情况,主要是闰年的2月和平年的2月
int n;
scanf("%d",&n);
while(n--){
scanf("%d:%d:%d %d.%d.%d",&hour,&minute,&second,&day,&month,&year);
if(year<2000||year>50000)
return 1;
int s=0;
int days=0;
days=days+(year-2000)*365;
// if(isRunYear(year)==1)这种方法是错误的,如果输入的这一年是闰年,则将月改了后,月都变成了29,没有了28
//dayofmonth[2]=29;
int yy;
yy=year;
while(year>=2000)
{
int x=year-1;
if(isRunYear(x)==1)
days+=1;
year--;
}
int i;
for(i=0;i<month;i++){
days+=dayofmonth[isRunYear(yy)][i];
}
days+=day-1;
myear=days/1000;
days=days%1000;
mmonth=days/100+1;
mday=days%100+1;
s=(hour*3600+minute*60+second)*125/108;
mhour=s/10000;
s-=mhour*10000;
mmin=s/100;
msec=s-mmin*100;
printf("%d:%d:%d %d.%d.%d\n",mhour,mmin,msec,mday,mmonth,myear);
}
return 0;
}
-