-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
77 lines (61 loc) · 2.03 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<!DOCTYPE html>
<!-- saved from url=(0049)http://www.shuizilong.com/swamp/game/Nibbles.html -->
<html lang="en">
<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<!--document.getElementById('div').innerHTML="你好,请采纳!";-->
<div>
<div id="equation">1+1=</div>
<input type="text" id="result" size="6" value="">
<input type="submit" id="submit2" size="6" value="submit" onclick="calc()">
</div>
<!--
<div>
<br>
<input type="text" id="guess" size="6" maxlength="6" value="111111">
<input type="submit" id="Submit1" size="6" value="submit" onclick="gogogo()">
</div>
-->
<script type="text/javascript">
var target = [1, 2, 3, 4, 5, 6];
for (var j=0;j<6;++j)
target[j] = parseInt(Math.random() * 6);
var a, b, op;
RefreshEquation();
function RefreshEquation(){
a = parseInt(Math.random() * 100);
b = parseInt(Math.random() * 100);
if (parseInt(Math.random() * 2) == 0) op = '+';
else op = '-';
document.getElementById('equation').innerHTML= a + op + b + "=";
}
function calc(){
var c = parseInt(document.getElementById('result').value);
var z = 0; if (op == '+') z = a + b; else z = a - b;
if (z == c){
alert("Yes");
RefreshEquation();
}
else alert("No");
}
function gogogo() {
//console.log();
var guess = document.getElementById("guess").value;
var A = 0, B = 0;
/*for (var i=0;i<6;++i){
for (var j=0;j<6;++j){
if (guess[i] == target[j]){
if (i == j) ++A;
else ++B;
}
}
}*/
for (var i=0;i<6;++i)
if (guess[i]==target[i])++A;
// console.log
alert(A + "A" + B + "B");
}
</script>
</body>
</html>