输入两个日期, 求之间的天数?
不知哪里有问题, 指教。。。#include<stdio.h>
struct date{
int days;
int monthes;
int year;
};
int main(void)
{
long int N(struct date day);
long double N1,N2,result;
struct date thisday, nextday;
printf("Enter the date of start:");
scanf("%d%d%d", &thisday.monthes, &thisday.days, &thisday.year);
printf("Enter the date of end:");
scanf("%d%d%d", &nextday.monthes, &nextday.days, &nextday.year);
N1=N(nextday);
N2=N(thisday);
result=N1-N2;
printf("the days is: %ld\n", result);
return 0;
}
long int N(struct date day)
{
int f(struct date a), g(struct date b);
long int Days;
Days=1461*f(day)/4+153*g(day)/5+day.days;
return Days;
}
int f(struct date a)
{
long int p;
if(a.monthes<=2)
p=a.year-1;
else p=a.year;
return p;
}
int g(struct date b)
{
long int q;
if(b.monthes<=2)
q=b.monthes+13;
else q=b.monthes+1;
return q;
}