作者pattyhouse (Stupid Cupid~)
看板Visual_Basic
标题[.NET] 我的中序转後序有点问题请问该怎麽改?
时间Wed May 24 13:06:08 2006
程式码如下
Public Sub turn(ByVal str() As String
Dim i As Integer
For i = 0 And i < str.Length To i + 1
If (Array.IndexOf(sun, str(i)) >= 0 Or (Array.IndexOf(cal2, str(i)) >= 0)) Then
If (str(i) = "*" Or str(i) = "/") Then
While (top > -1 AndAlso (Stack(top) = "*" Or Stack(top) = "/"))
sol += pop(i)
push(str(i))
End While
ElseIf (str(i) = "+" Or str(i) = "-") Then
While (top > -1 AndAlso (Stack(top) = "*" Or Stack(top) = "/"))
sol += pop(i)
End While
While (top > -1 AndAlso (Stack(top) = "+" Or Stack(top) = "-"))
sol += pop(i)
End While
push(str(i))
Else
push(str(i))
End If
ElseIf (Array.IndexOf(cal3, str(i)) >= 0) Then
While (Stack(top) <> "(")
sol += pop(i)
End While
top = top - 1
Else
sol = sol + str(i)
End If
While (top > -1)
sol += pop(i)
End While
Console.WriteLine(sol)
Next
end sub
Sub demo_test()
Dim t1 As test
Dim sol = " "
Dim enter As Integer
Console.WriteLine("**************************************************")
Console.WriteLine("** 中序转後序 **")
Console.WriteLine("**************************************************")
Console.Write("请输入中序式:")
Dim input As String = Console.ReadLine()
t1.turn(input)
^^^^^^^^^^^^^^^
Console.ReadLine()
End Sub
只是撷取程式片段,还不确定程式能跑,
一直卡在t1.turn(input)这行,说无法转换string的值
老师说把Public Sub turn(ByVal str() As String)的str()括号拿掉
但是里面程式中的str(i)就会有问题了!
不晓得该怎麽改,第一次学.net,有点头大,先谢谢唷!
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 203.73.7.242