C语言NextDay编程!

#include "stdio.h"
int IsLeapYear(int Year);//判断是不是闰年。
int IsCurrentDate(int Year,int Month,int Day);//是不是正确的日期。
int ReturnNextDay(int Year,int Month,int Day);//返回下一天,也有判断是不是正确的日期。
int LeapYear_Month_SumDay[12]={31,29,31,30,31,30,31,31,30,31,30,31};//闰年数组,保存各月天数。
void main()
{
 int Year=0,Month=0,Day=0,NextDay=0;
 printf("pleace enter right Date(example:2005 6 27):/n");
 scanf("%d%d%d",&Year,&Month,&Day);
 NextDay=ReturnNextDay(Year,Month,Day);
 
 switch (NextDay)
 {
 case 0: printf("not a current date/n");
  break;
 case 1:
  if (Month==12)
  {
   Year++;
   Month=1;
  }
  else
  {
   Month++;
  }
  break;
 }
 if (NextDay!=0) printf("The you input next date is %d-%d-%d.Thank use bye bye!/n",Year,Month,NextDay);
}

 

int IsLeapYear(int Year)
{
 if (Year%4==0)
 {
  if (Year%400) return 1;
  else
  {
   if (Year%100==0) return 0;
   else return 1;
  }
 }
 else
 {
  return 0;
 }
}


int IsCurrentDate(int Year,int Month,int Day)
{
 if ((Year<0) && (Year>9999) && (Month>12) && (Month<1) && (Day<1) &&(Day>31) )return 0;
 else return 1;
}

int ReturnNextDay(int Year,int Month,int Day)
{
 int ThisMonthSumDay;
 if (IsCurrentDate(Year,Month,Day)==1)
 {
  ThisMonthSumDay=LeapYear_Month_SumDay[Month-1];
  if (Month==2)
  {
   if (IsLeapYear(Year)==0) ThisMonthSumDay--;
  }
  if (Day<ThisMonthSumDay)
  {
   return ++Day;
  }
  else
  {
   if (Day==ThisMonthSumDay)
   {
    return 1;
   }
   else
   {
    return 0;
   }
  }
 }
 else
 {
  return 0;
 }
}
 

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值