#include <stdio.h>
int main()
{
int y;
printf("请输入年份,回车介绍\n");
scanf("%d",&y);
if((y%4==0&&y%100!=0)||y%400==0)
{
printf("%d是闰年",y);
}else
{
printf("%d是平年",y);
}
return 0;
}
Java语言:
import java.util.*;
public class xx {
public static void main(String[] args){
Scanner in=new Scanner (System.in);
System.out.println("请输入年份,回车结束");
int rp=in.nextInt();
if(rp%4==0&&rp%100!=0||rp%400==0){
System.out.println(rp+"是闰年");
}else{
System.out.println(rp+"是平年");
}
}
}