这个文件不留了吧~~~ #1

Closed
zhaoxin wants to merge 1 commits from (deleted):master into master
Showing only changes of commit 582c4dde8d - Show all commits

View File

@ -1,41 +0,0 @@
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="../style/common.css" />
<title>判断是否是闰年</title>
</script></head>
<body>
<h1>判断是否是闰年</h1>
<h2>作者: 赵海洋</h2>
<input type="text" id="year" placeholder="输入年份" />
<button onclick="check()">判断</button>
<script>
// 判断是否是闰年
function isleap(year) {
if (year == 0) return '没有公元0年'
if (year < 0) return '不支持公元前的年份'
if (!year.match(/\d+/)) return '年份格式不正确'
if (!year.match(/\d+/)) return ''
return (
(year / 4 == Math.floor(year / 4) && year / 100 != Math.floor(year / 100)) ||
(year / 400 == Math.floor(year / 400) && year / 3200 != Math.floor(year / 3200)) ||
year / 172800 == Math.floor(year / 172800)
)
}
function check() {
let result = isleap(year.value)
if (result === true) {
alert('是闰年')
} else if (result === false) {
alert('不是闰年')
} else {
alert(result)
}
}
</script>
</body>
</html>