程序编写∶判断年份是闰年还是平年

输入一个年份,判断是闰年还是平年并输出。(用if选择结构)


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int year;
    cin >> year;
    if ((year % 100 != 0 && year % 4 == 0) || (year % 400 == 0))
        cout << "闰年";
    else
        cout << "平年";
    return 0;
}

if(year%4==0||year%400==0)
{
if(year%100!=0)
printf("闰年");
else
printf("平年");
}