#include<stdio.h>
int main()
{
int is_leap(int year);
int year,month,day;
scanf("%d/%d/%d",&year,&month,&day);
int time[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}};
int i;
int sum=0;
for(i=1;i<month;i++)
{
sum+=time[is_leap(year)][i];
}
sum+=day;
printf("%d",sum);
return 0;
}
int is_leap(int year)
{
if((year%4==0&&year%100!=0)||year%400==0) return 1;
else return 0;
}
练习7-9 计算天数
最新推荐文章于 2022-11-04 17:26:03 发布