不知道叫什么


私信TA

用户名:dotcpp0620197

访问量:2193

签 名:

等  级
排  名 15029
经  验 802
参赛次数 0
文章发表 7
年  龄 0
在职情况 学生
学  校 东北林业大学
专  业 计算机类

  自我简介:

解题思路:

注意事项:

参考代码:

#include <stdio.h>

#include <stdlib.h>


struct date

{

    int year;

    int month;

    int day;

};


int func(int year)

{

    if((year % 400 == 0)||((year % 100 != 0)&&(year % 4 == 0)))

        return 1;

    else

        return 0;

}

int main()

{

    struct date Date;

    scanf("%d %d %d",&Date.year,&Date.month,&Date.day);

    int day[12] = {31,28,31,30,31,30,31,31,30,31,30,31};

    int n = 0,i;

    if(func(Date.year))

    {

        if(Date.month > 2)

        {

            for(i = 0;i < Date.month - 1;i++)

                n += day[i];

            n = n + Date.day + 1;

        }

        else

        {

            for(i = 0;i < Date.month;i++)

                n += day[i];

            n = n + Date.day;

        }

    }

    else

    {

        for(i = 0;i < Date.month - 1;i++)

            n += day[i];

        n = n + Date.day;

    }

    printf("%d\n",n);

    return 0;

}


 

0.0分

0 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答

代码解释器

  评论区