-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0d3d239
commit f2f8655
Showing
15 changed files
with
135 additions
and
7 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Scientific Calculator</title> | ||
</head> | ||
<body> | ||
<h1>Scientific Calculator</h1> | ||
<input type="text" id="input"> | ||
<button onclick="calculate()">Calculate</button> | ||
<script> | ||
function calculate() { | ||
// Declare variables | ||
var num1 = Number(document.getElementById('input').value); | ||
var num2 = Number(document.getElementById('input').value); | ||
var operator = document.getElementById('operator').value; | ||
|
||
// Perform calculation based on operator | ||
switch (operator) { | ||
case '+': | ||
result = num1 + num2; | ||
break; | ||
case '-': | ||
result = num1 - num2; | ||
break; | ||
case '*': | ||
result = num1 * num2; | ||
break; | ||
case '/': | ||
result = num1 / num2; | ||
break; | ||
default: | ||
result = "Invalid operator"; | ||
} | ||
|
||
// Display the result | ||
document.getElementById('input').value = result; | ||
} | ||
</script> | ||
</body> | ||
</html> |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>随机数生成器</title> | ||
<style> | ||
input { | ||
margin-bottom: 10px; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<center> | ||
<div style="max-width: 600px;text-align: left;"> | ||
<h1>随机数生成器</h1> | ||
<p>本程序使用Javascript函数“Math.random()”执行随机数抽取</p> | ||
<label for="min">最小值:</label> | ||
<input type="number" id="min" required><br> | ||
|
||
<label for="max">最大值:</label> | ||
<input type="number" id="max" required><br> | ||
|
||
<label for="decimals">整数(填写“0”)/小数(填写精确到几位小数):</label> | ||
<input type="number" id="decimals" required><br> | ||
|
||
<label for="quantity">一次性抽出数量:</label> | ||
<input type="number" id="quantity" required><br> | ||
|
||
<label for="repeat">是否重复抽出:</label> | ||
<select id="repeat"> | ||
<option value="true">是</option> | ||
<option value="false">否</option> | ||
</select><br> | ||
|
||
<button onclick="generateRandomNumbers()">生成随机数</button> | ||
|
||
<div id="result"></div> | ||
</div> | ||
</center> | ||
<script> | ||
function generateRandomNumbers() { | ||
var min = parseInt(document.getElementById("min").value); | ||
var max = parseInt(document.getElementById("max").value); | ||
var decimals = parseInt(document.getElementById("decimals").value); | ||
var quantity = parseInt(document.getElementById("quantity").value); | ||
var repeat = document.getElementById("repeat").value === "true"; | ||
|
||
var result = document.getElementById("result"); | ||
result.innerHTML = ""; | ||
|
||
for (var i = 0; i < quantity; i++) { | ||
var randomNum = Math.random() * (max - min) + min; | ||
randomNum = parseFloat(randomNum.toFixed(decimals)); | ||
|
||
if (!repeat) { | ||
result.innerHTML += "随机数 " + (i + 1) + ": " + randomNum + "<br>"; | ||
} else { | ||
result.innerHTML += "随机数 " + (i + 1) + ": " + randomNum + "<br>"; | ||
} | ||
} | ||
} | ||
</script> | ||
<center><div style="position: fixed;bottom: 0;width: 100%;padding: 20px;display: flex;justify-content: center;align-items: center;"> | ||
<a target="_blank" href="./blog/open.html"><a href="https://ipw.cn/ssl/?site=oldsai.cn" title="本站支持SSL安全访问" target='_blank'><img style='display:inline-block;vertical-align:middle' alt="本站支持SSL安全访问" src="../images/ssl-s1.svg"></a> | ||
<a target="_blank" href="../open.html"><span9>Copyright</span9></a> © 2022-2024 PangXitong. All rights reserved. Open source project by <a target="_blank" href="https://github.com/PangXitong"><span9>PangXitong</span9></a>. | ||
</div></center> | ||
</body> | ||
</html> |
This file contains 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