C语言填空:判断月份的天数

#include <stdio.h>
//从键盘输入一个年份和月份,输出该月的天数 
main()
{
    int year,month;
    scanf("【1】",&year,&month);
    switch(month)
    {
        case 1:
        case 3:
        case 5:
        case 7:
        case 8:
        case 10:
        case 12:printf("本月【2】天!");break;
        case 2:{
            if(【3】)
            printf("本月29天!");
            else printf("本月【4】天!");
            【6】;
        defaults:printf("本月【5】天!");
            break;
        }
            
    }


    getchar();
 }
#include <stdio.h>
//从键盘输入一个年份和月份,输出该月的天数 
main()
{
    int year,month;
    scanf("%%d",&year,&month);
    switch(month)
    {
        case 1:
        case 3:
        case 5:
        case 7:
        case 8:
        case 10:
        case 12:printf("本月31天!");break;
        case 2:{
            if(year%4==0&&year%100!=0 || year%400==0)
            printf("本月29天!");
            else printf("本月28天!");
            break;
        defaults:printf("本月30天!");
            break;
        }
            
    }


    getchar();
 }

 

posted @ 2023-02-09 15:09  myrj  阅读(327)  评论(0编辑  收藏  举报