方法一,转载自 “Wolfgang_baozi”
import java.io.;
import java.math.;
import java.util.*;
public class Main
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
//TODO
int n;
n = in.nextInt();
String ok=“no”;
if(n%100 != 0 && n%4 == 0) ok = “yes”;
if(n%400 == 0) ok = “yes”;
System.out.println( ok );
}
}
方法二:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in=new Scanner(System.in);
int y=in.nextInt();
if(y>=1&&y<=3000) {
if((y%4==0&&y%100!=0)||(y%400==0)) {
System.out.println("yes");
}
else {
System.out.println("no");
}
}
else {
System.out.println();
}
}
}