标签:style ar sp java on bs amp as line
闰年的条件: 能被4整除且不能被100整除的为闰年或能被400整除 则为闰年
java写法:
---------------------------------------------------
import java.util.*;
public class LeapYear{
public static void main(String[] args){
Syste.out.println("请输入年份:");
Scanner sc = new Scanner(System.in);
int year = sc.nextInt();
if(year%4 == 0 && year%100 != 0 || year%400 == 0){
System.out.println(year + "年是闰年");
}else{
System.out.println(year + "年非闰年");
}
}
}
---------------------------------------------------
Python写法:
---------------------------------------------------
#coding=utf-8
year = int(raw_input(‘请输入年份:‘))
if year%4 == 0 and year%100 != 0 or year%400 == 0:
print year,‘年是闰年‘
else:
print year,‘年非闰年‘
---------------------------------------------------
标签:style ar sp java on bs amp as line
原文地址:http://www.cnblogs.com/dtest/p/4127289.html