输入两个日期,计算之间相差多少天。 用了两种方法实现,第二种利用结构体,代码比较清晰,其余的都一样
1.普通的写法
复制代码代码如下:
#include
int leapyear(int year)
{
if((year%4==0 && year%100!=0) || year%400==0)
return 1;
else
return 0;
}
int days(int *day1, int *day2)
{
int i=0;
int *tmp;
int diff = 0;
const int month[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
if(day1[0] == day2[0])
{
if(day1[1] == day2[1])
{
diff = day1[2] - day2[2];
diff = (diff