fix some file extensions
This commit is contained in:
parent
68f8f3e56b
commit
f3a896c724
789 changed files with 91 additions and 62 deletions
56
Task/Stack/VBScript/stack.vb
Normal file
56
Task/Stack/VBScript/stack.vb
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
class stack
|
||||
dim tos
|
||||
dim stack()
|
||||
dim stacksize
|
||||
|
||||
private sub class_initialize
|
||||
stacksize = 100
|
||||
redim stack( stacksize )
|
||||
tos = 0
|
||||
end sub
|
||||
|
||||
public sub push( x )
|
||||
stack(tos) = x
|
||||
tos = tos + 1
|
||||
end sub
|
||||
|
||||
public property get stackempty
|
||||
stackempty = ( tos = 0 )
|
||||
end property
|
||||
|
||||
public property get stackfull
|
||||
stackfull = ( tos > stacksize )
|
||||
end property
|
||||
|
||||
public property get stackroom
|
||||
stackroom = stacksize - tos
|
||||
end property
|
||||
|
||||
public function pop()
|
||||
pop = stack( tos - 1 )
|
||||
tos = tos - 1
|
||||
end function
|
||||
|
||||
public sub resizestack( n )
|
||||
redim preserve stack( n )
|
||||
stacksize = n
|
||||
if tos > stacksize then
|
||||
tos = stacksize
|
||||
end if
|
||||
end sub
|
||||
end class
|
||||
|
||||
dim s
|
||||
set s = new stack
|
||||
s.resizestack 10
|
||||
wscript.echo s.stackempty
|
||||
dim i
|
||||
for i = 1 to 10
|
||||
s.push rnd
|
||||
wscript.echo s.stackroom
|
||||
if s.stackroom = 0 then exit for
|
||||
next
|
||||
for i = 1 to 10
|
||||
wscript.echo s.pop
|
||||
if s.stackempty then exit for
|
||||
next
|
||||
Loading…
Add table
Add a link
Reference in a new issue