程序编写∶判断年份是闰年还是平年(简单点的代码)

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

#include<iostream>
using namespace std;
int main(){
    int y;
    cin>>y;
    if(y%4==0&&y%100!=0 || y%400==0){
        cout<<"闰年";
    }else{
        cout<<"平年";
    }
    return 0;
}

#include <stdio.h>
main()
{
int year;
printf("请输入年数");
scanf("%d,&year");
if((year%4==0)&&year%100!=0
printf("%d年为闰年",year);
else if(year %400==0)
printf("%d年为闰年",year);
else
printf("%d年为平年",year);
}