C语言作业——反复校验用户输入的生日,包括年、月、日。直到年、月、日都合法。

来源:互联网 发布:人人网外推软件 编辑:程序博客网 时间:2024/05/29 00:32
//    7.(****)反复校验用户输入的生日,包括年、月、日。直到年、月、日都合法。

    
//    int year,mouth,day;
//    int i=1;
//    while (i) {
//        printf("请输入正确的生日:\n");
//        scanf("%d%d%d",&year,&mouth,&day);
//        if (year>0 && year<2015) {
//            
//            if ( year%400==0||( year%4==0 && year%100!=0))
//            {
//                
//                if (mouth<=12&&mouth>0)
//                {
//                    if (mouth==1||mouth==3||mouth==5||mouth==7||mouth==8||mouth==10||mouth==12)
//                    {
//                        if (day<=31&&day>0)
//                        {printf("it is right style.\n") ;i=0;}
//                        else {
//                            printf("it is not right style .\n");
//                            
//                        }
//                        
//                    } else if(mouth==2) {
//                        if (day<30&&day>0)
//                        {printf("it is right style.\n") ;i=0;}
//                        else {printf("it is not right style .\n");}
//                    }else if (mouth==4||mouth==6||mouth==9||mouth==11){
//                        
//                        if (day<=30&&day>0)
//                        {printf("it is right style.\n") ;i=0;}
//                        else {printf("it is not right style .\n");}
//                        
//                    }
//                }else {printf("it is not right style .\n");}
//                
//            }
//            
//            
//            else{
//                
//                if (mouth<=12 && mouth>0)
//                {
//                    
//                    if (mouth==1 || mouth==3 || mouth==5 || mouth==7 || mouth==8 || mouth==10 || mouth==12)
//                    {
//                        if (day<=31&&day>0)
//                        {printf("it is right style.\n") ;i=0;}
//                        else {printf("it is not right style .\n");}
//                        
//                    } else if(mouth==2) {
//                        if (day<=28&&day>0)
//                        {printf("it is right style.\n") ;i=0;}
//                        else {printf("it is not right style .\n");}
//                    }else if (mouth==4||mouth==6||mouth==9||mouth==11){
//                        
//                        if (day<=30&&day>0)
//                        {printf("it is right style.\n") ;i=0;}
//                        else {printf("it is not ok.\n");}
//                        
//                    }
//                }else {printf("it is not right style .\n");}
//            }
//            
//        }
//        else{
//            printf("it is not right style .\n");
//        }
//    }
    
    

0 0
原创粉丝点击