(單選,填字母)。 A.dj.vbp B.dj.frm C.jd.exe D.dj.vbw (2)請在橫線處填上合適的代碼。 Const max=1000 Dim n As Integer'存放學生人數 Dim xh(1 To max) As String'數組xh存放學生的學籍號 Dim xm(1 To max) As String'數組xm存放學生的姓名 Dim bj(1 To max) As Integer'數組bj存放學生的班級 Dim fs(0 To max) As Single'數組fs存儲學生的原始分數 Dim ffdj(0 To max) As String'數組ffdj存儲學生的賦分等級 Private Sub Command1_Click
Dim p(1 To 8)As Single,dj(1 To 8)As String Dim i As Integer,j As Integer,pos As Integer,last As Integer Dim st As String,it As Integer,sit As Single ‘從數據庫中讀入學生學號、姓名、班級和原始成績,分別存入數組 xh、xm、bj 和 fz中,代碼略 p(1)=0.03:p(2)=0.07:p(3)=0.16:p(4)=0.24:p(5)=0.24:p(6)=0.16:p(7)=0.07:p(8)=0.03:dj(1)=“A“:dj(2)=“B+“:dj(3)=“B“:dj(4)=“C+“:dj(5)=“C“:dj(6)=“D+“:dj(7)=“D“:dj(8)=“E“ For i=2 To 8 ①
'計算到該等級累計所占比例 Next i For i=1 To n-1 For j=1 To n-i If fs(j)<fs(j+1)and bj(j)<b(j+1)Then st=xh(j):xh(j)=xh(j+1):xh(j+1)=st st=xm(j):xm(j)=xm(j+1):xm(j+1)=st it=bj(j):bj(j)=bj(j+1):bj(j+1)=it sit=fs(j):fs(j)=fs(j+1):fs(j+1)=sit End If Next j Next i pos=1 For i=1 To 8 last=②
'人數四舍五入取整 Do While fs(last+1)=fs(last) last=last+1'處理切分位置的同分數學生 Loop Do While ③
ffdj(pos)=dj(i) pos=pos+1 Loop Next i For i=1 To n List2.AddItem xh(i)+““+xm(i)+““+Str(bj(i))+““+Str(fs(i))+““+ffdj(i) Next i End Sub
倍。 (2)根據上述掃描算法,其 VB 代碼實現如下,請在橫線處填入合適的代碼。 Dim a(0 To 1000)As Integer'存儲原矩陣數據,按行優先存儲 Dim b(0 To 1000)As Integer'存儲Z形掃描后數據 Dim c(0 To 1000)As Integer'存儲行程編碼壓縮后數據 Dim n As Integer ‘矩陣導入代碼略,以行優先存儲在a數組中,如例子中數據存儲順序為“57,45,0,23,0,0…” Private Sub Command2_Click
Dim choice As Integer'1:向右移動;2:向右上移動;3向下移動 4向左下移動 Dim row As Integer,col As Integer,i As Integer,j As Integer Dim pre As Integer,count As Integer choice=1:row=0:col=0:i=0 Do While (row<>n-1 Or col<>n-1) b(i)=a(row*n+col):i=i+1 If choice=1 Then ①
If row=0 Then choice=4 Else choice=2 ElseIf choice=2 Then row=row-1:col=col+1 If ②
Then choice=1 ElseIf col=n-1 Then choice=3 End If ElseIf choice=3 Then row=row+1 If col=0 Then choice=2 Else choice=4 ElseIf choice=4 Then row=row+1:col=col-1 If row=n-1 Then choice=1 ElseIf col=0 Then choice=3 End If End If Loop b(i)=a(n*n-1):j=0:pre=b(0):count=0 For i=0 To n*n-1'輸出Z形序列,并進行行程壓縮 If pre=b(i) Then count=count+1 Else c(j)=pre:c(j+1)=count ③
pre=b(i):j=j+2 End If Next i c(j)=pre:c(j+1)=count Text1.Text=““ For i=0 To j+1 Text1.Text=Text1.Text+Str(c(i))+“,“ Next i End Sub