输入一个日期,判断该年是否是闰年,该月处于什么季节,该月有多少天。

来源:互联网 发布:人工智能科技园 编辑:程序博客网 时间:2024/04/27 17:46
#include<stdio.h>
int main()
{
    int i,year,month,day;
    printf("请依次输入年月日:\n");
    scanf("%d%d%d",&year,&month,&day);
    if((year%100!=0&&year%4==0)||year%400==0)
    {
           printf("该年是闰年:\n");
           if(month==2)
           {
                printf("该月有29天.\n");
             }
            else if(month==1||month==3||month==5||month==7||month==8||month==10||month==12)
           {
                printf("该月有31天.\n");
            }
             else
             {
                 printf("该月有30天.\n");
             }
    }
    else
    {
              printf("该年不是闰年.\n");
              if(month==2)
              {
                     printf("该月有28天.\n");
              }
              else if(month==1||month==3||month==5||month==7||month==8||month==10||month==12)
              {
                     printf("该月有31天.\n");
              }
             else
             {
                     printf("该月有30天.\n");
             }
    }


    if(month>=3&&month<=5)
    {
        printf("该月处于春季.\n");
    }
    else if(month>=6&&month<=8)
    {
        printf("该月处于夏季.\n");
    }
    else if(month>=9&&month<=11)
    {
        printf("该月处于秋季.\n");
    }
    else if(month>=2&&month<=12)
    {
        printf("该月处于冬季.\n");
    }
}
1 0
原创粉丝点击