實(shí)現(xiàn)該功能的VB程序如下,但加框處代碼有錯(cuò),請(qǐng)改正。 Dim nam(100)As String'存放學(xué)生姓名 Dim sex(100)As String'存放學(xué)生性別 Dim math(100)As Long'存放學(xué)生數(shù)學(xué)成績 Dim su(100)As Long'存放學(xué)生總分成績 Dim k As Integer'k變量用來存學(xué)生人數(shù) Private Sub Form_Load ( ) ‘將數(shù)據(jù)庫中的數(shù)據(jù)分別存儲(chǔ)在相應(yīng)的變量中并在列表框中顯示出來 ‘代碼略 End Sub Private Sub Command1_Click ( ?。?br />Dim mmax As Integer,gmax As Integer,flagm As Boolean,flagg As Boolean i=1:flagm=True:flagg=True Do While ① mmax=0:gmax=0 flagm=False:flagg=False For j=i To k-i+1 If sex(j)=“男“And su(j)>su(mmax) Then mmax=j If sex(j)=“女“And su(j)>su(gmax) Then gmax=j Next j If mmax<>0 Then flagm=True t=nam(mmax):nam(mmax)=nam(i):nam(i)=t t=sex(mmax):sex(mmax)=sex(i):sex(i)=t t=math(mmax):math(mmax)=math(i):math(i)=t t=su(mmax):su(mmax)=su(i):su(i)=t End If If gmax<>0 Then flagg=True If Then② gmax=mmax t=nam(gmax):nam(gmax)=nam(k-i+1):nam(k-i+1)=t t=sex(gmax):sex(gmax)=sex(k-i+1):sex(k-i+1)=t t=math(gmax):math(gmax)=math(i):math(i)=t t=su(gmax):su(gmax)=su(k-i+1):su(k-i+1)=t Else t=nam(gmax):nam(gmax)=nam(k-i+1):nam(k-i+1)=t t=sex(gmax):sex(gmax)=sex(k-i+1):sex(k-i+1)=t t=math(gmax):math(gmax)=math(k-i+1):math(k-i+1)=t t=su(gmax):su(gmax)=su(k-i+1):su(k-i+1)=t End If End If i=i+1 Loop For i=1 To k List2.AddItem nam(i)+““+sex(i)+““+Str(math(i))+““+Str(su(i)) Next i End Sub 程序中①處改為
(1)已知k=38,則數(shù)組元素b(26)對(duì)應(yīng)值是數(shù)組a中的。 (2)實(shí)現(xiàn)該功能的VB程序如下,請(qǐng)?jiān)跈M線處填入合適的代碼: Private Sub Command1_Click ( ) Dim a(1 To 1000)As Integer,b(1 To 1000)As Integer Dim n As Integer,m As Integer Dim s As String,s1 As String,c As Integer,ch As String s=Text1.Text:Text2.Text=““ n=Len(s) k=1 For i=1 To n'獲取字符的二進(jìn)制數(shù)據(jù)存放在數(shù)組a
中 n=Asc(Mid(s,i,1)) Do While n<>0 a(k)=n Mod 2 n=n\2 Text2.Text=Text2.Text+Str(a(k)) k=k+1 Loop Next i ①
List1.Clear For m=1 To (k-1)\16'對(duì)字符二進(jìn)制按規(guī)則進(jìn)行位變換,變換后的數(shù)據(jù)存放在數(shù)組b
中并輸出 For i=1 To 4 b(16*(m-1)+4*(i-1)+1)=a((m-1)*16+i) ②
Next i For i=1 To 3 b(16*(m-1)+4*(i-1)+3)=a((m-1)*16+10+i) b(16*(m-1)+4*(i-1)+2)=a((m-1)*16+17-i) Next i For i=1 To 2 b(16*(m-1)+13+i)=a((m-1)*16+4+i) Next i For i=1 To 4 s1=““ For j=1 To 4 s1=s1+Str(b(16*(m-1)+(i-1)*4+j)) Next j List1.AddItem s1 Next i List1.AddItem““ Next m
s1=““ For i=((k-1)\16)*16+1 To k-1 b(i)=a(i) If ③ Then s1=s1+Str(a(i)) List1.AddItem s1 s1=““ Else s1=s1+Str(a(i)) End If Next i List1.AddItem s1 Text3.Text=““ For i=1 To k-1 Text3.Text=Text3.Text+Str(b(i)) Next i End Sub (1)實(shí)現(xiàn)上述功能,請(qǐng)?jiān)跈M線處填入適當(dāng)?shù)拇a: 程序中①處填入的是