#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<vector>
#include<iterator>
#define N 10001
using namespace std;
bool leap(int year)
{
if(year%4==0&&year%100!=0||year%400==0)
return 1;
else
return 0;
}
int days(int month, int day)
{
int p[13]={0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int i;
for(i=0; i<month; i++){
day+=p[i];
}
return day;
}
int main()
{
int year, month, day, x;
cout << "请输入年月日:";
cin >> year >> month >> day ;
x = days(month, day);
if(leap(year))
x++;
cout << "该日是该年的第" << x << "天" << endl;
return 0;
}
给出年月日,计算该日是该年的第几天
最新推荐文章于 2023-05-05 20:56:03 发布