POJ 2210 Metric Time G++
程序员文章站
2022-07-15 10:46:25
...
#include <iostream>
#include <cstdio>
using namespace std;
int hs[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int he[13]={0,0,31,59,90,120,151,181,212,243,273,304,334};
int tian(int dy,int mh,int yr)//与 1.1.2000 相差几天
{
int sum=dy-1;
/*
for(int i=1;i<mh;i++)
{
if(i==2 && ((yr%4==0 && yr%100!=0)||(yr%400==0)))//闰年
{
sum=sum+29;
}else
{
sum=sum+hs[i];
}
}*/
sum=sum+he[mh];
if(mh>2 && ((yr%4==0 && yr%100!=0)||(yr%400==0)))//闰年
{
sum=sum+1;
}
/*
for(int i=2000;i<yr;i++)
{
if((i%4==0 && i%100!=0)||(i%400==0))//闰年
{
sum=sum+366;
}else
{
sum=sum+365;
}
}*/
if (yr !=2000)//抄博友 巧妙
sum =sum+ 366 + 365 * (yr - 1 - 2000) + (yr - 1 - 2000) /4- (yr -1 - 2000) / 100+ (yr -1-2000) / 400;
return sum;
}
int miao(int hr,int mn,int sc)
{
return sc+mn*60+hr*60*60;
}
int main()
{
/*
for(int i=2;i<13;i++)
{
he[i]=he[i-1]+hs[i-1];
cout<<he[i]<<" ";
}
cout<<endl;*/
int n;
scanf("%d",&n);
for(int i=0;i<n;i++)
{
int hr,mn,sc,dy,mh,yr;
scanf("%d:%d:%d %d.%d.%d",&hr,&mn,&sc,&dy,&mh,&yr);
int msec=miao(hr,mn,sc);
int mday=tian(dy,mh,yr);
//cout<<msec<<" "<<mday<<endl;
msec=msec*(125.0/(108.0));
//cout<<msec<<endl;
printf("%d:%d:%d %d.%d.%d\n",(msec/10000)%10,(msec%10000)/100,msec%100,
(mday%100)+1,((mday%1000)/100)+1,mday/1000);
}
return 0;
}