#include<bits/stdc++.h> //万能头文件
using namespace std;
int a[2][13]={{0,31,28,31,30,31,30,31,31,30,31,30,31}, {0,31,29,31,30,31,30,31,31,30,31,30,31}};
//列举平年和闰年每月的天数
bool leap(int year) //判断是否是闰年
{
return year%4==0&&year%100!=0||year%400==0;
}
int main() //主函数
{
int year,month,day,ans=0;
while(~scanf("%d %d %d",&year,&month,&day))
{
for(int i=0;i<month;i++)
{
ans+=a[leap(year)][i];
}
ans+=day;
cout<<ans<<endl;
}
return 0;
}
计算天数(c++)
最新推荐文章于 2024-04-27 11:13:02 发布