标题:输入两个日期, 求之间的天数?
只看楼主
forrest0227
Rank: 1
等 级:新手上路
帖 子:31
专家分:0
注 册:2007-12-10
 问题点数:0 回复次数:1 
输入两个日期, 求之间的天数?
不知哪里有问题, 指教。。。
#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;
}
搜索更多相关主题的帖子: 天数 int date thisday 
2007-12-26 22:30
sunkaidong
Rank: 4
来 自:南京师范大学
等 级:贵宾
威 望:12
帖 子:4496
专家分:141
注 册:2006-12-28
得分:0 
你找一下07年上半年的程序员考试的下午题目上面有类似的题目
2007-12-26 22:38



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-194499-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.129819 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved