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 @   myrj  阅读(558)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
点击右上角即可分享
微信分享提示