简单程序——年月日的判断

来源:互联网 发布:u盘必装软件 编辑:程序博客网 时间:2024/06/05 21:49

简单程序——年月日的判断

#include "stdio.h"void main(){   int a,b,c;   printf("Please input year/month/day:\n");   scanf("%d/%d/%d",&a,&b,&c);   if(a%4==0&&a%100!=0||a%400==0)    {       if(b==2)        {          if (0<c&&c<30) printf("%d/%d/%d",a,b,c);          printf("\n");       }   }    else        {           if(c==2)            {               if (0<c&&c<29) printf("%d/%d/%d",a,b,c);               printf("\n");           }       }           if((0<b&&b<2)||(2<b&&b<13))       {           switch(b)           {           case 1:           case 3:           case 5:           case 7:           case 8:           case 10:           case 12:if(0<c&&c<32)printf("%d/%d/%d",a,b,c);break;           case 4:           case 6:           case 9:           case 11:if(0<c&&c<31) printf("%d/%d/%d",a,b,c);break;           default :printf("enter data error!\n");           }           printf("\n");       }}

如有错误,请多多指正,谢谢。

原创粉丝点击