(單選,填字母:A.Command 1/B.Text 1/C.List 1)。 (2)實(shí)現(xiàn)考場(chǎng)分配功能的VB程序如下,請(qǐng)?jiān)跈M線處填入合適的代碼。 (3)程序中加框處代碼有錯(cuò),請(qǐng)改正。 Dim n As Integer,y As String Dim cla(1 To 20)As Integer,num(I To 20)As Integer Dim room As Integer'存儲(chǔ)考場(chǎng)號(hào) Dim seat As Integer'存儲(chǔ)座位號(hào) Function fm(k As Integer) As String '返回整數(shù)k(1≤k≤99)對(duì)應(yīng)的數(shù)字字符串,不足兩位左側(cè)補(bǔ)“0”,代碼略 End function Private Sub Command 1_ Click ( ?。?br />'從Text l中讀取入學(xué)年份存入變量y,從數(shù)據(jù)庫(kù)中讀取該入學(xué)年份的班級(jí)數(shù)據(jù), '將班級(jí)個(gè)數(shù)存入變量n(1<n≤20),各班班號(hào)和人數(shù)分別存入數(shù)組ela和num, '各班班號(hào)均大于0,各班人數(shù)均未超過(guò)總?cè)藬?shù)的一半, '將數(shù)組cla和num按班級(jí)人數(shù)降序排列后,顯示在List l中,代碼略 End Sub Private Sub Command 2_ Click ( ?。?br />Dim i As Integer,t As Integer,s As Integer Dim choice As Integer,m As Integer,f As Boolean room=1:seat=1:choice=0 ① Do While f=True If cla (1)<>choice Then m=1 Else m=2 choice=cla(m) '在列表框List2中顯示準(zhǔn)考證號(hào)、考場(chǎng)號(hào)、座位號(hào) List 2.Addltem y+fm(ela(m))+fm(num(m))+″″+fm(room)+″″+fm(seat) seat=seat+1 If seat>30 Then
seat=1 End If num(m)=num(m)-1 For i=②To n-1'維護(hù)班級(jí)降序序列(按未分配人數(shù)) If num(i)<num(i+1)Then t=num(i):num(i)=num(i+1):num(i+1)=t s=ela(i):ela(i)=ela(i+1):ela(i+1)=s Else Exit For'ExitFor表示退出循環(huán) End If Next i If③Then f=False Loop End Sub
)(填數(shù)值)。 (2)實(shí)現(xiàn)上述功能的VB程序如下,請(qǐng)?jiān)跈M線處填入合適的代碼。 Const m=1000'溫度數(shù)據(jù)和溫差數(shù)據(jù)包含的記錄數(shù)都少于1000 Dim na As Integer,nb as integer'A、B城數(shù)據(jù)分別有na和nb個(gè)記錄 Dim ha(m)As Integer'ha(i)存儲(chǔ)A城第i個(gè)記錄中的溫度 Dim ta(m)As Integer'ta(i)存儲(chǔ)A城第i個(gè)記錄中的截止時(shí)間 Dim hb(m)As Integer'hb(i)存儲(chǔ)B城第i個(gè)記錄中的溫度 Dim tb(m)As Integer'tb(i)存儲(chǔ)B城第i個(gè)記錄中的持續(xù)時(shí)長(zhǎng) Dim h(m)As Integer'h(i)存儲(chǔ)計(jì)算結(jié)果第i個(gè)記錄中的溫差 Dim t(m)As Integer't(i)存儲(chǔ)計(jì)算結(jié)果第i個(gè)記錄中的持續(xù)時(shí)長(zhǎng) Private Sub Command l _Click ( ?。?br />Dim i As Integer,j As Integer Dim p0 As Integer,p1 As Integer,diff As Integer Dim n As Integer'兩城溫差數(shù)據(jù)的記錄個(gè)數(shù) '讀取兩城數(shù)據(jù),存入變量na,nb及數(shù)組ha,ta,hb,tb中,代碼略 For i=2 To nb tb(i)=①'將B城第i個(gè)記錄中的持續(xù)時(shí)長(zhǎng)轉(zhuǎn)換為截止時(shí)間 Next i i=1:j=1 n=0 p0=0 Do While i<na And i<=nb diff ha(i)-hb(j) pl=ta(i) If ②Then i=i+1 If p1>=tb (j) Then pl=tb(i) j=j+1 End if If n=0 Or diff<>h(n) Then n=n+l h(n)=diff t(n)=pl-p0 Else ③ End If p0=pl Loop '輸出兩城溫差數(shù)據(jù),代碼略 End Sub