Rabu, 15 April 2009

Tumpukan (Stack)

1. Program Stack 1 :

<html>
<head>
<title>Contoh Implementasi Push dan POP pada Stack</title>
</head>

<body bgcolor="aqua">
<font color="green" face="comic sans ms">
<script type = "text/javascript">
var stack = new Array;
stack.push ("A");
stack.push ("B");
stack.push ("C");
document.write ("Stack :"+stack.toString() +"<br>");

var YangDiAmbil = stack.pop();
document.write ("Data Yang Diambil : "+YangDiAmbil);
document.write ("<br>");
document.write ("Isi Stack Terakhir :"+stack.toString());
</script>
</body>
</html>

Outputnya :

Tidak ada komentar:

Posting Komentar