Created
May 18, 2012 07:27
-
-
Save geta6/2723765 to your computer and use it in GitHub Desktop.
入力された値までの総和を求めます
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset='utf-8'> | |
<title>SumToN</title> | |
</head> | |
<body> | |
<h1>Parameter</h1> | |
<div> | |
<label for='dcml'>N :</label> | |
<input id='dcml' type='number' step='1'> | |
</div> | |
<div> | |
<input id='calc' type='button' value='Calculate'> | |
</div> | |
<h1>Output</h1> | |
<div> | |
<label for='puts'>Sum :</label> | |
<input id='puts' type='text' value='0'> | |
</div> | |
<script> | |
(function () { | |
(function () { return document.getElementById('calc') }()).addEventListener('click', function () { | |
var d = (function(){ return document.getElementById('dcml') }()).value - 0, | |
p = document.getElementById('puts'); | |
p.value = 0; | |
while (d > 0) p.value = p.value - 0 + d--; | |
}, false); | |
}()); | |
</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
<html> | |
<head> | |
<title>Sum</title> | |
</head> | |
<body> | |
<script type="text/javascript"> | |
<!-- | |
function calculate(){ | |
// フォームからのパラメータ取得 | |
var N = document.getElementById('N'); | |
var answer = document.getElementById('answer'); | |
// パラメータの整数化と詰め替え | |
N = parseInt(N.value); | |
// 答えを入れる変数 | |
var sum=0; | |
// カウンタ | |
var count; | |
// 足し込み処理 | |
answer.value = sum; // 結果の表示 | |
} | |
//--> | |
</script> | |
<form> | |
<table> | |
<tr><td><b>パラメータ:</b></td></tr> | |
<tr> | |
<td>1) N:</td> | |
<td><input type="text" id="N" ></td> | |
</tr> | |
<tr><td></td> | |
<td><input type="button" value="計算" onclick="calculate();"></td> | |
</tr> | |
<tr><td><b>出力</b></td></tr> | |
<tr> | |
<td>2) 1からNまでの和:</td> | |
<td><input type="text" id="answer"></td> | |
</tr> | |
</table> | |
</form> | |
</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
var t = new Turtle(1), a = 100, r = 144; | |
for (var i = 0; i < 5; i++) { | |
t.fd(a); t.rt(r) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment