Created
August 18, 2017 15:44
-
-
Save cuduy197/de568d6497bc1fb1c1cb8e38970c2270 to your computer and use it in GitHub Desktop.
Tính Can Chi // source https://jsbin.com/tucemav
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>Tính Can Chi</title> | |
<style id="jsbin-css"> | |
@import url('https://fonts.googleapis.com/css?family=Comfortaa'); | |
body { | |
font-family: 'Comfortaa'; | |
text-align: center; | |
background: plum; | |
color: white; | |
margin: 0; | |
} | |
button { | |
background: orange; | |
color: white; | |
font-size: 2em; | |
border-radius: 10px; | |
border: 2px solid white; | |
padding: .2em; | |
} | |
button:hover { | |
background: coral; | |
} | |
</style> | |
</head> | |
<body> | |
<h1>Viết chương trình, nhập năm dương lịch sau đó hiển thị năm âm lịch. <br> <code>VD: 2017 -> Đinh Dậu</code></h1> | |
<i>Để hiển thị nhập trong javascript dùng <br> <code>promt('Noi dung muon hỏi','Gía trị sẵn')</code></i> | |
<br> <br> <i>Biết năm 0 là năm Canh Thân</i> | |
<hr> | |
<h2>Chương trình mẫu: </h2> | |
<button onclick='chuyenDoi()'>Tính Can Chi</button> | |
<br> | |
<h1><i id="result"></i></h1> | |
<script id="jsbin-javascript"> | |
//cuduy197 | |
chuyenDoi = () => { | |
let inputYear = prompt('Hãy nhập năm dương lịch cần tính', 2017); | |
let nam = Number(inputYear); | |
let Can = ['Canh','Tân','Nhâm','Qúy', 'Giáp','Ất', 'Bính','Đinh','Mậu','Kỷ']; | |
let Chi = ['Thân','Dậu','Tuất','Hợi','Tý','Sửu','Dần','Mão','Thìn','Tỵ','Ngọ','Mùi']; | |
alert(`Năm ${nam} là:\n${Can[nam%10]} ${Chi[nam%12]}`); | |
console.log(`Năm ${nam} là\n${Can[nam%10]} ${Chi[nam%12]}`); | |
document.getElementById('result').innerText= `Năm ${nam} là ${Can[nam%10]} ${Chi[nam%12]}`; | |
}; | |
</script> | |
<script id="jsbin-source-css" type="text/css">@import url('https://fonts.googleapis.com/css?family=Comfortaa'); | |
body { | |
font-family: 'Comfortaa'; | |
text-align: center; | |
background: plum; | |
color: white; | |
margin: 0; | |
} | |
button { | |
background: orange; | |
color: white; | |
font-size: 2em; | |
border-radius: 10px; | |
border: 2px solid white; | |
padding: .2em; | |
} | |
button:hover { | |
background: coral; | |
}</script> | |
<script id="jsbin-source-javascript" type="text/javascript">//cuduy197 | |
chuyenDoi = () => { | |
let inputYear = prompt('Hãy nhập năm dương lịch cần tính', 2017); | |
let nam = Number(inputYear); | |
let Can = ['Canh','Tân','Nhâm','Qúy', 'Giáp','Ất', 'Bính','Đinh','Mậu','Kỷ']; | |
let Chi = ['Thân','Dậu','Tuất','Hợi','Tý','Sửu','Dần','Mão','Thìn','Tỵ','Ngọ','Mùi']; | |
alert(`Năm ${nam} là:\n${Can[nam%10]} ${Chi[nam%12]}`); | |
console.log(`Năm ${nam} là\n${Can[nam%10]} ${Chi[nam%12]}`); | |
document.getElementById('result').innerText= `Năm ${nam} là ${Can[nam%10]} ${Chi[nam%12]}`; | |
}; | |
</script></body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@import url('https://fonts.googleapis.com/css?family=Comfortaa'); | |
body { | |
font-family: 'Comfortaa'; | |
text-align: center; | |
background: plum; | |
color: white; | |
margin: 0; | |
} | |
button { | |
background: orange; | |
color: white; | |
font-size: 2em; | |
border-radius: 10px; | |
border: 2px solid white; | |
padding: .2em; | |
} | |
button:hover { | |
background: coral; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//cuduy197 | |
chuyenDoi = () => { | |
let inputYear = prompt('Hãy nhập năm dương lịch cần tính', 2017); | |
let nam = Number(inputYear); | |
let Can = ['Canh','Tân','Nhâm','Qúy', 'Giáp','Ất', 'Bính','Đinh','Mậu','Kỷ']; | |
let Chi = ['Thân','Dậu','Tuất','Hợi','Tý','Sửu','Dần','Mão','Thìn','Tỵ','Ngọ','Mùi']; | |
alert(`Năm ${nam} là:\n${Can[nam%10]} ${Chi[nam%12]}`); | |
console.log(`Năm ${nam} là\n${Can[nam%10]} ${Chi[nam%12]}`); | |
document.getElementById('result').innerText= `Năm ${nam} là ${Can[nam%10]} ${Chi[nam%12]}`; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment