#include <iostream>
using namespace std;
double u = 100000.0 / 86400.0;
bool run(int year)
{
if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)return true;
else return false;
}
int month_days[] = { 31,28,31,30,31,30,31,31,30,31,30,31 };
int SUMDAYS[] = { 0,31,59,90,120,151,181,212,243,273,304,334,365 };
int SUMDAYS_run[] = { 0,31,60,91,121,152,182,213,244,274,305,335,366 };
string weekdays[] = { "Sunday", "Monday", "Tuesday", "Wednesday","Thursday","Friday","Saturday" };
int main()
{
int normal_sum;
int special_sum;
int n;
cin >> n;
while (n--)
{
int hour,minute,second,day,month,year;
int mhour,mminute,msecond,mday,mmonth,myear;
scanf("%d:%d:%d %d.%d.%d", &hour, &minute, &second, &day, &month, &year);
normal_sum = second + 60 * minute + 3600 * hour;
special_sum = u * normal_sum * 1.0;
msecond = special_sum % 100;
special_sum /= 100;
mminute = special_sum % 100;
special_sum /= 100;
mhour = special_sum % 100;
int sumdays = 0;
for (int i = 2000;i < year;i++)
{
if (run(i))
{
sumdays += 366;
}
else sumdays += 365;
}
if (run(year))
{
sumdays += SUMDAYS_run[month - 1] + day;
}
else
{
sumdays += SUMDAYS[month - 1] + day;
}
myear = sumdays / 1000;
mmonth = (sumdays / 100) % 10 + 1;
mday = sumdays % 100;
if (sumdays % 1000 == 0)
{
myear--;
mmonth = 10;
mday = 100;
}
if (sumdays % 100 == 1)
{
mmonth = 1;
mday = 1;
}
cout << mhour << ":" << mminute << ":" << msecond << " " << mday << "." << mmonth<< "." << myear << endl;
}
return 0;
}
/*
1 426 146158 731 2001000 2001001
1.1.0 26.5.0 58.2.146 31.8.0 100.10.2000 1.1.2001 7.3.6848
*/
1170: 6202特殊日历计算
最新推荐文章于 2024-08-24 23:00:16 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)