<body>
<center><h2>九九乘法表</h2>
<hr>
<table border="1">
<script language="JavaScript">
// 變數宣告
var i, j;
// 表格標題
document.write("<tr><td></td>");
for (i=1;i<=9;i++)
document.write("<td><b>" + i + "</b></td>");
document.write("<tr>");
// 巢狀迴路
for (i=1;i<=9;i++){
document.write("<tr>");
document.write("<td><b>" + i + "</b></td>");
j = 1;
while (j <= 9){
document.write("<td>");
document.write(i + "*" + j + "=" + i*j);
document.write("</td>");
j++;
}
document.write("<tr>");
}</script>
</table></center>
</body>
沒有留言:
張貼留言