The problem of data structure is very important, if you can describe the input and output data structure of a problem, then this question is very promising, the data structure is not the patent of C language, the real data structure is pseudo code. The following stack class is the code I used to collect others, and in fact whenever I consider a program problem, especially a complex one, it should be thought of what kind of data to describe your input and output.
'**********************************************
' VBS STACK Class
' Push (string) into stack
' GetTop the top element of the stack
' Pop off stack top element
' IsEmpty whether the stack is empty
' Isfull whether the stack is full (Pmax set size, can be modified by itself)
'
' Wooden bird 2002.10.10
' http://www.aspsky.net/
'**********************************************
Class Stack
Private PARR, pstring, Pmax
Private tab
Private Sub Class_Initialize ()
TAB=CHR (9)
pmax=1000 ' max capacity
End Sub
Private Sub Class_Terminate ()
If IsArray (PARR) Then
Erase PARR
End If
End Sub
Public function push (str)
If Str<> "" and InStr (Str,tab) <1 and not Isfull then
If IsArray (PARR) Then
Pstring=join (Parr,tab)
End If
Pstring=pstring & Tab & STR
Parr=split (Pstring,tab)
Push=true
Else
Push=false
End If
End Function
Public Function GetTop ()
If not IsArray (PARR) <0 Then
Gettop=null
Else
If UBound (PARR) <0 Then
Gettop=null
Else
Gettop=parr (Ubound (PARR))
End If
End If
End Function
Public Function Pop ()
If not IsArray (PARR) Then
Pop=false
Else
If Ubound (PARR) <0 Then
Pop=false
Else
Pstring=join (Parr,tab)
Pstring=left (Pstring,instrrev (Pstring,tab)-1)
Parr=split (Pstring,tab)
Pop=true
End If
End If
End Function
Public Function IsEmpty ()
If not IsArray (PARR) Then
Isempty=true
Else
If Ubound (PARR) <0 Then
Isempty=true
Else
Isempty=false
End If
End If
End Function
Public Function Isfull ()
If not IsArray (PARR) Then
Isfull=false
Else
If UBound (PARR) <pmax Then
Isfull=false
Else
Isfull=true
End If
End If
End Function
End Class