在一行中输入一个整数
,满足
。
输出一个字符串,若
为闰年,输出 "yes"(不含双引号);否则输出 "no"(不含双引号)。
2000
yes
能被
整除,因此是闰年。
1900
no
能被
整除但不能被
整除,因此不是闰年。
import java.util.Scanner;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
// 注意 hasNext 和 hasNextLine 的区别
while (in.hasNextInt()) { // 注意 while 处理多个 case
int a = in.nextInt();
if (a % 400 == 0 || (a % 4 == 0 && a % 100 != 0)) {
System.out.println("yes");
}else {
System.out.println("no");
}
}
}
} import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
while(scanner.hasNext()){
int toJudgeLeapYear = scanner.nextInt();
//1、能被4整除但不能被100整除
//2、能被400整除
if(toJudgeLeapYear % 4 == 0 && toJudgeLeapYear % 100 != 0 || toJudgeLeapYear % 400 == 0){
System.out.println("yes");
}else{
System.out.println("no");
}
}
}
} import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int x = sc.nextInt();
if (x % 1000 == 0) {
System.out.print("yes");
} else {
if (x % 4 == 0) {
if (x % 100 != 0) {
System.out.print("yes");
} else {
System.out.print("no");
}
} else {
System.out.print("no");
}
}
}
} import java.util.*;
public class Main{
public static String getleapyear(int n){
if(n%4==0&&n%100!=0|n%400==0){
return "yes";
}
else
return "no";
}
public static void main(String args[]){
Scanner input=new Scanner(System.in);
int n=input.nextInt();
System.out.print(getleapyear(n));
}
} import java.util.Scanner;
/**
*
* @Title 判断闰年
* @Description 判断一个整数n是否是闰年
* 普通闰年:公历年份是4的倍数的,且不是100的倍数,为普通闰年(如2004年、2020年就是闰年)。
* 世纪闰年:公历年份是整百数的,必须是400的倍数才是世纪闰年(如1900年不是世纪闰年,2000年是世纪闰年)
* 输入描述:
* 输入一个整数n (1≤n≤2018)
* 输出描述:
* 是闰年输出"yes" 否则输出"no"
* @author weijunfu<ijunfu @ qq.com>
* @date 2022/03/16 10:51
* @version 1.0.0
*
*/
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int i = in.nextInt();
if(i%400 == 0 || (i%100!=0 && i%4==0)) {
System.out.println("yes");
} else {
System.out.println("no");
}
in.close();
}
}