16.小明編寫某 VB 程序,其功能如下:文本框 Text1 里輸入數學表達式(假設表達式的 長度小于等于 100),在列表框 List1 里輸出所有配對括號在表達式中的位置.例如在文本框 Text1 里入:“12*(3-(1+2))*3”,程序運行效果如圖所示. 實現上述功能的 VB 代碼如下,在劃線的地方填入合適代碼,完善程序 Private Sub Command1_Click ( ?。?br />Dim s As String Dim a(1To 100)As Integer Dim i As Integer,top As Integer s=Text1.Text i=1 top=0 Do While i<=Len(s) If Mid(s,i,1)=“(“Then top=top+1 ① End If If Mid(s,i,1)=“)“Then List1.AddItem Str(a(top))+““+Str(i) ② End If i=i+1 Loop End Sub.
(選填字母:A.解析算法/B.枚舉算法). (2)為了實現程序的功能,請在橫線處填入合適的代碼. Private Sub Command1_Click ( ) Dim a As Integer,c As Integer,w As Integer,i As Integer Dim s As String,k As String c=0 For m=1To 100 k=““ i=2*m Do While i>0 a=i Mod 2
k=str(a)+k Loop
For n=1To Len(k) s=Mid(k,n,1) If s=“1“Then w=w+1 Next n If w=4Then c=c+1