<html>
<head>
<title>KOTAK SILANG BINTANG</title>
</head>
<body>
<script type="text/javascript">
var n = prompt("masukkan bilangan");
var i = 1;
var j = 1;
for(i = 1 ; i <= n ; i ++){
for(j = 1 ; j <= n ; j ++)
{
if (i == 1 || i == n || j == 1 || j == n){
if (i <= n){
document.write("* ");
}
}
else if(( i == j ) || (j == n - i+1 )){
document.write("* ");
}
else
{
document.write(" ");
}
}
document.write("<br/>");
}
</script>
</body>
</html>
Tidak ada komentar:
Posting Komentar