-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsquare.html
More file actions
38 lines (34 loc) · 1.08 KB
/
square.html
File metadata and controls
38 lines (34 loc) · 1.08 KB
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
<html>
<title>Magic Square</title>
<script src="magic.js" lang="Javascript"></script>
<script>
var matrixSize = 0;
var data = window.location.hash;
if((data != null) && (data.length > 2) && (data.charAt(1) == "m"))
{
matrixSize = parseInt(data.substring(2));
//alert(matrixSize);
}
function Generate(n)
{
if(n <= 0) return;
var m = FillTable(n);
document.write("<table style='border-style:solid;border-width:1px;border-color:#400040;'>");
for(var i = 0; i < n; i++)
{
document.write("<tr>");
for(var j = 0; j < n; j++)
{
document.write("<td style='border-style:solid;border-width:1px;border-color:#e1e1e1;' align='center'>" + m[i][j] + "</td>");
}
document.write("</tr>");
}
document.write("</table>");
}
</script>
<body >
<script>
document.write("<center><h3 style='color:#400040'>Magic Square [" + matrixSize + "x" + matrixSize + "]</h3>");
Generate(matrixSize);
document.write("<p>[<a href='#' onClick='window.print();return false;'>Print</a>]</p></center>");
</script>