想请问一下“给定一个日期,输出这个日期是该年的第几天”的问题

1.代码

#include"stdio.h"
int main()
{
    int year,month,day;
    scanf("%d %d %d\n",&year,&month,&day);
    if(((year%4)==0&&(year%100)!==0)||year%400==0)
    {
        if(8<=month<=12)
        {
                if(month%2==0)
            {
                printf("%d",(month/2+1)*31+(month/2)*30);
            }
            if((month%2)!==0)
            {
                {
                    printf("%d",(month/2)*31+(month/2-1)*30);
                }
            }
        }
        if(month<=7)
        {
            if((month%2)!==0)
            {
                printf("%d",(month/2+1)*31+(month/2)*30);
            }
            if(month%2==0)
            {
                if(month==2)
                {
                    printf("%d",31+day);
                }
                else
                {
                    printf("%d",(month/2)*31+(month/2-1)*30);
                }
            }
        }
    }
    else
    {
        if(8<=month<=12)
        {
                if(month%2==0)
            {
                printf("%d",(month/2+1)*31+(month/2)*30);
            }
            if((month%2)!==0)
            {
                {
                    printf("%d",(month/2)*31+(month/2-1)*30);
                }
            }
        }
        if(month<=7)
        {
            if((month%2)!==0)
            {
                printf("%d",(month/2+1)*31+(month/2)*30);
            }
            if(month%2==0)
            {
                    printf("%d",(month/2)*31+(month/2-1)*30);

            }
        }
    }
    return 0;
}

2.错误

--------------------配置: mingw5 - CUI Debug, 编译器类型: MinGW--------------------

检查文件依赖性...
正在编译 C:\Users\X\Documents\C-Free\Temp\未命名7.cpp...
[Error] C:\Users\X\Documents\C-Free\Temp\未命名7.cpp:6: error: expected primary-expression before '=' token
[Error] C:\Users\X\Documents\C-Free\Temp\未命名7.cpp:14: error: expected primary-expression before '=' token
[Error] C:\Users\X\Documents\C-Free\Temp\未命名7.cpp:23: error: expected primary-expression before '=' token
[Error] C:\Users\X\Documents\C-Free\Temp\未命名7.cpp:48: error: expected primary-expression before '=' token
[Error] C:\Users\X\Documents\C-Free\Temp\未命名7.cpp:57: error: expected primary-expression before '=' token
[Warning] C:\Users\X\Documents\C-Free\Temp\未命名7.cpp:69:2: warning: no newline at end of file

构建中止 未命名7: 5 个错误, 1 个警告


if(8<=month<=12)
不能这么写,应该是
if(8<=month && month<=12)

if((month%2)!==0)
应该是
if((month%2)!=0)

根据错误提示,第6,14,23,48,57,69等行的 !== ,改为 !=.
再有就是楼上所说的 8<=month<=12 这个问题,要分开写,用 && 连接