当前位置:编程学习 > C/C++ >>

c语言---简易日期加1天系统

 

考试要用,就写了,,,有同样需求的朋友拿走吧。

 

 

#include <stdio.h>

 

 

void main()                              //定义日期部分函数

 

 

{

       char tmps;

       do

       {

              printf("请输入一个日期(年 月 日)");

 

 

              int year,month,day,tmp;

 

 

              scanf("%d %d %d",&year,&month,&day);

 

 

              if(year < 1000 || year > 9999)             //判断年份

              {

 

 

                     printf("年输入的不对,请输入4位正整数");

 

 

              }

              else if(month > 12 || month < 1)           //判断月份

              {

 

 

                     printf("月输入的不对,请输入1-12的正整数");

 

 

              }

              else

              {

 

 

                     switch(month)                          //定义每个月的天数

                     {

 

 

                     case 1 :

                            tmp = 31;

                            break;

 

 

                     case 2:

                            tmp = 28;

                            break;

 

 

                     case 3 :

                            tmp = 31;

                            break;

 

 

                     case 4:

                            tmp = 30;

                            break;

 

 

                     case 5 :

                            tmp = 31;

                            break;

                     case 6 :

                            tmp = 30;

                            break;

 

 

                     case 7 :

                            tmp = 31;

                            break;

 

www.zzzyk.com

                     case 8:

                            tmp = 31;

                            break;

 

 

                     case 9 :

                            tmp = 30;

                            break;

 

 

                     case 10:

           &nbs

补充:软件开发 , C语言 ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,