logo
YourData+
玉东数据
首页专升本CLASSROOM博客工具

C语言程序设计习题集习题五:选择结构程序设计

pdf
2. (填空)
2. [填空]

以下程序计算某年某月有几天。其中判别闰年的条件是:能被4整除但不能被100整除的年是闰年,能被400整除的年也是闰年。请在_______内填入正确内容。

main(  )
{
    int yy, mm, len;
    printf("please input year, month: ");
    scanf("%d %d", &yy, &mm);
    switch(mm)
    {
        case 1:
        case 3:
        case 5:
        case 7:
        case 8:
        case 10:
        case 12: _______; break;
        case 4:
        case 6:
        case 9:
        case 11: len=30; break;
        case 2:

            if (yy%4==0&&yy%100!=0||yy%400==0) _______;
            else     _______;
            break;
        default: printf ("input error"); break;
    }
    printf("the length of %d %d is %d\n", yy, mm, len);
}
答案:
解析:

Copyright ©

YourData+2025.甘肃玉东数据有限公司
应用合作解决方案MUI-Remix
18919890888微信同号
陇ICP备2021001826号