#include <iostream>
#include<math.h>
#include<vector>
using namespace std;
int main()
{
int year, day;
cin >> year>> day;
int year1[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };
int year2[12] = { 31,29,31,30,31,30,31,31,30,31,30,31 };
int tag = 1;
if ((year % 400 == 0) || ((year % 4 == 0) && year % 100 != 0))
tag = 2;
int month = 0;
int date = 0;
while (day > 0)
{
if (tag == 1)
{
for (int i = 0;i < 12;i++)
{
if (day - year1[i] < 0)
{
date = day ;
day = 0;
month = i+1 ;
break;
}
else
{
day = day - year1[i];
}
}
}
if (tag == 2)
{
for (int i = 0;i < 12;i++)
{
if (day - year2[i] < 0)
{
date = day ;
day = 0;
month = i+1 ;
break;
}
else
{
day = day - year2[i];
}
}
}
}
cout << month << endl << date;
return 0;
}
20150902----日期计算
最新推荐文章于 2021-12-07 16:38:27 发布