Sabtu, 24 September 2011

KOTAK SILANG BINTANG

<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("*&nbsp; ");
}
}
else if(( i == j ) || (j == n - i+1 )){
document.write("*&nbsp; ");
}
else
{
document.write("&nbsp;&nbsp;&nbsp;&nbsp;");
}

}
document.write("<br/>");
}
</script>
</body>
</html>

Tidak ada komentar:

Posting Komentar