首页 > 其他 > 详细

输入日期计算天数

时间:2014-08-14 23:06:48      阅读:431      评论:0      收藏:0      [点我收藏+]

#include <stdio.h>
void main()
{
int year,month,day,daynum;
printf("请输入年月日,用,号隔开,格式列(2014,5,12)\n");
scanf("%d,%d,%d",&year,&month,&day);
switch(month)
{
case 1:
daynum=day;
break;
case 2:
daynum=30+day;
break;
case 3:
daynum=28+30+day;
break;
case 4:
daynum=31+28+30+day;
break;
case 5:
daynum=30+31+28+30+day;
break;
case 6:
daynum=31+30+31+28+30+day;
break;
case 7:
daynum=30+31+30+31+28+30+day;
break;
case 8:
daynum=31+30+31+30+31+28+30+day;
break;
case 9:
daynum=31+31+30+31+30+31+28+30+day;
break;
case 10:
daynum=30+31+31+30+31+30+31+28+30+day;
break;
case 11:
daynum=31+30+31+31+30+31+30+31+28+30+day;
break;
case 12:
daynum=30+31+30+31+31+30+31+30+31+28+30+day;
break;
}
if (year%4==0&&year%100!=0||year%400==0 )
{
daynum=daynum+1;
}
printf("该日期是当年的第%d天\n",daynum);
}

输入日期计算天数,布布扣,bubuko.com

输入日期计算天数

原文:http://www.cnblogs.com/wenhuan/p/3913289.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!