解题思路以及注意事项:

  1. 今天给大家分享的这题不难,但很搞笑哈。

  2. 好久没写过怎么恶心的代码了,今天给大家开开眼哈。

实例代码:

#include"stdio.h"
struct year
{
    int years;
    int month;
    int days;
};
int main()
{
    int t=0;
    struct year yeari;
    scanf("%d %d %d",&yeari.years,&yeari.month,&yeari.days);
    if(((yeari.years%4)==0)&&(yeari.years%100)!=0||((yeari.years%400)==0))
    {
        if(yeari.month==1)
        {
            t=yeari.days;
        }
        if(yeari.month==2)
        {
            t=yeari.days+31;
        }
        if(yeari.month==3)
        {
            t=yeari.days+31+29;
        }
        if(yeari.month==4)
        {
            t=yeari.days+31+29+31;
        }
        if(yeari.month==5)
        {
            t=yeari.days+31+29+31+30;
        }
        if(yeari.month==6)
        {
            t=yeari.days+31+29+31+30+31;
        }
        if(yeari.month==7)
        {
            t=yeari.days+31+29+31+30+31+30;
        }
        if(yeari.month==8)
        {
            t=yeari.days+31+29+31+30+31+30+31;
        }
        if(yeari.month==9)
        {
            t=yeari.days+31+29+31+30+31+30+31+31;
        }
        if(yeari.month==10)
        {
            t=yeari.days+31+29+31+30+31+30+31+31+30;
        }
        if(yeari.month==11)
        {
            t=yeari.days+31+29+31+30+31+30+31+31+30+31;
        }
        if(yeari.month==12)
        {
            t=yeari.days+31+29+31+30+31+30+31+31+30+31+30;
        }
    }
    else
    {
        if(yeari.month==1)
        {
            t=yeari.days;
        }
        if(yeari.month==2)
        {
            t=yeari.days+31;
        }
        if(yeari.month==3)
        {
            t=yeari.days+31+28;
        }
        if(yeari.month==4)
        {
            t=yeari.days+31+28+31;
        }
        if(yeari.month==5)
        {
            t=yeari.days+31+28+31+30;
        }
        if(yeari.month==6)
        {
            t=yeari.days+31+28+31+30+31;
        }
        if(yeari.month==7)
        {
            t=yeari.days+31+28+31+30+31+30;
        }
        if(yeari.month==8)
        {
            t=yeari.days+31+28+31+30+31+30+31;
        }
        if(yeari.month==9)
        {
            t=yeari.days+31+28+31+30+31+30+31+31;
        }
        if(yeari.month==10)
        {
            t=yeari.days+31+28+31+30+31+30+31+31+30;
        }
        if(yeari.month==11)
        {
            t=yeari.days+31+28+31+30+31+30+31+31+30+31;
        }
        if(yeari.month==12)
        {
            t=yeari.days+31+28+31+30+31+30+31+31+30+31+30;
        }

    }
    printf("%d",t);
    return 0;
}

相信大家都懂了,可以在下方评论区留言,批判批判哈

点赞(0)
 

0.0分

0 人评分

C语言网提供由在职研发工程师或ACM蓝桥杯竞赛优秀选手录制的视频教程,并配有习题和答疑,点击了解:

一点编程也不会写的:零基础C语言学练课程

解决困扰你多年的C语言疑难杂症特性的C语言进阶课程

从零到写出一个爬虫的Python编程课程

只会语法写不出代码?手把手带你写100个编程真题的编程百练课程

信息学奥赛或C++选手的 必学C++课程

蓝桥杯ACM、信息学奥赛的必学课程:算法竞赛课入门课程

手把手讲解近五年真题的蓝桥杯辅导课程

评论列表 共有 1 条评论

海洋之心 7年前 回复TA
#include<stdio.h>
int month_day[2][13]={{0,31,29,31,30,31,30,31,31,30,31,30,31},{0,31,28,31,30,31,30,31,31,30,31,30,31}};
struct day
{
    int year;
    int month;
    int day;
    int flag;
};
int to_day(struct day days);
int main(void)
{
    int year;
    int month;
    int day;
    struct day days;
    scanf("%d%d%d",&days.year,&days.month,&days.day);
    if((days.year%400==0)||(days.year%4==0 && days.year%100!=0))
    days.flag=0;
    else days.flag=1;
    printf("%d",to_day(days));
    return 0;
}
int to_day(struct  day days)
{
    int sum=0;
    for(int j=1;j<=days.month-1;j++)
    sum+=