Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- </head>
- <body>
- <script>
- //stek stavam elementi eden vrz drug, ima funkcii :s.peek(dava element na vrvo); s.pop(vade element od vrvo); s.push(stava element na vrvo);
- stack s;
- niza = [1, 4, 8, '+', 3, '*', '-', 0];
- for (i=0; niza[i]!=0; i++){
- if(proveri(niza[i])==true){
- s.push(niza[i]);
- }
- else if( tab[i]=='*'){
- var prva = s.pop;
- var vtora = s.pop;
- s.push(prva*vtora);
- }
- }
- console.log(s.peek);
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement