求大佬们指点,测试结果和题目不一样,是我的思路错了吗
假设人的心率为每分钟跳75下,编程从键盘输入你的出生年和今年的年份,然后以年为单位计算并输出从你出生开始到目前为止的生命中已有的心跳总数(要求考虑闰年)。程序运行结果示例1:
Input your birth year:1986↙
Input this year:2016↙
The heart beats in your life: 1183356000
求教各位大佬,
我的结果是1183464000,和结果差了一天,我想知道哪里错了
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
long int day,mine;
int long unsigned time;
int i,count=0;
int biryear,thyear,year,bigyear;
printf("Input your birth year:");
scanf("%d",&biryear);
printf("Input this year:");
scanf("%d",&thyear);
year=thyear-biryear;
for(i=biryear;i<=thyear;i++)
{
if(i%4==0)
{
if(i%400==0)
{
count++;
}
else
{
if(i%100!=0)
{
count++;
}
}
}
}
bigyear=year-count;
day=bigyear*365+count*366;
mine=day*24*60;
time=mine*75;
printf("The heart beats in your life: %lu",time);
return 0;
}