. (2)請(qǐng)?jiān)跈M線處填入合適的代碼. Dim a(1 To 1000)As Integer'存儲(chǔ)某科目的相關(guān)數(shù)據(jù),數(shù)組大小滿足處理要求 Dim n As Integer'該科目的學(xué)生總?cè)藬?shù) Private Sub Command1_Click( ?。?br />'從數(shù)據(jù)庫中讀取指定科目的各相關(guān)數(shù)據(jù),存儲(chǔ)在數(shù)組a中 Dim conn As New ADODB.Connection,rs As New ADODB.Recordset conn.ConnectionString=“Provider=Microsoft.ACE.OLEDB.12.0;Data Source=“+App.Path+“\students.jye.ai“ conn.Open Set rs.ActiveConnection=conn '本過程的其他語句略 End Sub Private Sub Command2_Click( ) Dim i As Integer,j As Interger,k As Integer,kt As Integer Dim c As Integer,zws As Single For i=1 To n-1
For j=i+1 To n If a(j)>a(k) Then kt=a(j):a(j)=a(k):a(k)=kt End If Next j Next i c=n\2 If n Mod 2=1 Then zws=
Else zws=(a(c)+a(c+1))/2 End If Text2.Text=Str(zws) End Sub.
①正數(shù):正整數(shù)補(bǔ)碼的數(shù)值即其二進(jìn)制表示. 例:12的8位二進(jìn)制表示00001100,最高位即符號(hào)位“0”表示正數(shù). ②負(fù)數(shù):除符號(hào)位外,所有位取反,然后+1. 例:-5的8位二進(jìn)制補(bǔ)碼表示方法如下,5對(duì)應(yīng)7位二進(jìn)制數(shù)為0000101 (原碼),所有位取反后為1111010(反碼),再加1后為1111011(補(bǔ)碼),再設(shè)置符號(hào)位為1,因此-5 用8位二進(jìn)制補(bǔ)碼表示為11111011. 小明設(shè)計(jì)了一個(gè)VB程序,點(diǎn)擊“補(bǔ)碼”按鈕Command1,將文本框Text1中輸入的整數(shù) n(-128≤n≤127)轉(zhuǎn)換成相應(yīng)的補(bǔ)碼,并在文本框Text2中輸出,程序結(jié)果如圖所示,請(qǐng)將橫線處的代碼補(bǔ)充完整. Private Sub Command1_Click ( ) Dim n As Integer,a As Integer,i As Integer Dim m(1To 8)As Integer Text2.Text=““ n=Val(Text1.Text) If n>=0The ‘計(jì)算二進(jìn)制原碼 For i=8To 2Step-l m(i)=n Mod 2 n=n\2 Next i ‘設(shè)置符號(hào)位 m(1)=0 Else n=-n ‘計(jì)算二進(jìn)制反碼 For i=8To 2Step-l m(i)=①
n=n\2 Next i ‘加1計(jì)算 i=8 Do While m(i)=1 ②
i=i-1 Loop m(i)=1 ‘設(shè)置符號(hào)位 m(1)=1 End If ’輸出結(jié)果 For i=l To 8 Text2.Text=Text2.Text & m(i) Next i End Sub (1)-27用8位二進(jìn)制補(bǔ)碼表示為