
(1)在表达式中输入15-22\5*2+7=,则输出的结果是 。
(2)实现上述功能的 VB 程序如下,请在划线处填入合适代码。
Function calculate(x As Integer, y As Integer, op As String) As Integer If op = "+" Then calculate = x + y
If op = "-" Then calculate = x - y If op = "*" Then calculate = x * y If op = "\" Then calculate = x \ y
End Function
Function state(op As String) As Integer If op = "#" Then state = -1
If op = "=" Then state = 1
If op = "+" Then state = 1
If op = "-" Then state = 1
'①
If op = "*" Then state = 3
End Function
Private Sub Command1_Click()
Dim s As String, length As Integer, t As String Dim k As Integer, q As Integer
Dim opt(0 To 3) As String Dim i As Integer
Dim s1 As String
Dim a(1 To 3) As Integer s = Text1.Text
length = Len(s)
t = "": k = 0: q = 0: opt(q) = "#"
For i = 1 To length s1 = Mid(s, i, 1)
If s1 >= "0" And s1 <= "9" Then
t = t + s1
Else
k = k + 1 a(k) = Val(t) t = ""Do While '②
a(k - 1) = calculate(a(k - 1), a(k), opt(q))
k = k - 1
q= q - 1
Loop
q = q + 1
'③
If s1 = "=" Then Label1.Caption = Str(a(1))
End If
Next i
End Sub
同类型试题

y = sin x, x∈R, y∈[–1,1],周期为2π,函数图像以 x = (π/2) + kπ 为对称轴
y = arcsin x, x∈[–1,1], y∈[–π/2,π/2]
sin x = 0 ←→ arcsin x = 0
sin x = 1/2 ←→ arcsin x = π/6
sin x = √2/2 ←→ arcsin x = π/4
sin x = 1 ←→ arcsin x = π/2


y = sin x, x∈R, y∈[–1,1],周期为2π,函数图像以 x = (π/2) + kπ 为对称轴
y = arcsin x, x∈[–1,1], y∈[–π/2,π/2]
sin x = 0 ←→ arcsin x = 0
sin x = 1/2 ←→ arcsin x = π/6
sin x = √2/2 ←→ arcsin x = π/4
sin x = 1 ←→ arcsin x = π/2

