某比賽項(xiàng)目由多位評委打分,然后根據(jù)項(xiàng)目難度系數(shù)計(jì)算最終得分。規(guī)則為:
最終得分=(所有評委打分總和-1個(gè)最高分-1個(gè)最低分)×項(xiàng)目難度系數(shù)
編寫VB程序,實(shí)現(xiàn)計(jì)算最終得分的功能。在文本框Text1中輸入項(xiàng)目難度系數(shù)和多位評委的打分,中間用“,”隔開并以“,”結(jié)尾,然后點(diǎn)擊計(jì)算按鈕,在文本框Text2中顯示最終得分。程序運(yùn)行界面如圖所示。
(1)程序中計(jì)算按鈕的對象名是 BB(單選,填字母:A.Command1/B.Cmd1/C.Cmd1_Click)。
(2)實(shí)現(xiàn)上述功能的VB程序如下,請?jiān)跈M線處填入合適的代碼。
(3)程序中加框處代碼有錯(cuò),請改正。
Private Sub Cmd1_Click ( ?。?/div>( )
Dim a(1 To 100)As Single
Dim i As Integer,j As Integer,k As Integer,m As Integer,n As Integer
Dim Tot As Single,tmp As Single
Dim s As String,v As String,ch As String
s=Text1.Text
n=1:v=““
m=1m=1
Do While n<=Len(s)
ch=Mid(s,n,1)
If ch<>“,“Then
v=v & ch
Else
a(m)=Val(v)
v=“”v=“”
m=m+1
End If
n=n+1
Loop
For i=2 To m-2
For j=m-1 To i+1 Step-1
If a(i)<a(j) Then
tmp=a(i):a(i)=a(j):a(j)=tmp
End If
Next j
Next i
Tot=0
For i=1 Tom 3 To m-23 To m-2
Tot=Tot+a(i)
Next i
Text2.Text=str(a(1)*Tot)str(a(1)*Tot)
End Sub【考點(diǎn)】冒泡排序算法及其實(shí)現(xiàn).【答案】B;( );m=1;v=“”;3 To m-2;str(a(1)*Tot)【解答】【點(diǎn)評】聲明:本試題解析著作權(quán)屬菁優(yōu)網(wǎng)所有,未經(jīng)書面同意,不得復(fù)制發(fā)布。發(fā)布:2024/6/27 10:35:59組卷:3引用:2難度:0.2
( )
Dim a(1 To 100)As Single
Dim i As Integer,j As Integer,k As Integer,m As Integer,n As Integer
Dim Tot As Single,tmp As Single
Dim s As String,v As String,ch As String
s=Text1.Text
n=1:v=““
m=1
m=1
Do While n<=Len(s)
ch=Mid(s,n,1)
If ch<>“,“Then
v=v & ch
Else
a(m)=Val(v)
v=“”
v=“”
m=m+1
End If
n=n+1
Loop
For i=2 To m-2
For j=m-1 To i+1 Step-1
If a(i)<a(j) Then
tmp=a(i):a(i)=a(j):a(j)=tmp
End If
Next j
Next i
Tot=0
For i=1 Tom
3 To m-2
3 To m-2
Tot=Tot+a(i)
Next i
Text2.Text=
str(a(1)*Tot)
str(a(1)*Tot)
End Sub
發(fā)布:2024/6/27 10:35:59組卷:3引用:2難度:0.2
相似題
-
1.有如下 Python 程序段:
運(yùn)行后列表中的值可能是( )發(fā)布:2024/12/18 21:0:2組卷:5引用:3難度:0.3 -
2.用VB編寫的函數(shù)bubble_sort是一個(gè)用冒泡方法實(shí)現(xiàn)排序的函數(shù),其調(diào)用時(shí)需要三個(gè)參數(shù):布爾類型參數(shù)sx來確定是升序還是降序,sx為True時(shí)為升序,否則為降序;整數(shù)型數(shù)組a
比如有一個(gè)整數(shù)型數(shù)組a(1 to 10)需要降序排序,可以直接這樣調(diào)用:
a
該函數(shù)VB代碼如下:
Function bubble_sort(sx As Boolean,a
Dim i,j,t As Integer
For i=1 To n-1
For j=
If
If a(j)<a(j-1)Then t=a(j):a(j)=a(j-1):a(j-1)=t
Else
If a(j)>a(j-1)Then t=a(j):a(j)=a(j-1):a(j-1)=t
End If
Next j
Next i
bubble_sort=a
End Function
請將代碼補(bǔ)充完整:
①
②發(fā)布:2024/12/20 20:30:1組卷:23引用:2難度:0.3 -
3.用選擇排序法對一組數(shù)據(jù)進(jìn)行升序排序,第一趟排序結(jié)束后的順序?yàn)?、6、9、3、7,則原始數(shù)據(jù)順序不可能的是( ?。?/h2>
發(fā)布:2024/12/18 23:0:1組卷:10引用:1難度:0.5
把好題分享給你的好友吧~~
APP開發(fā)者:深圳市菁優(yōu)智慧教育股份有限公司| 應(yīng)用名稱:菁優(yōu)網(wǎng) | 應(yīng)用版本:5.0.7 |隱私協(xié)議|第三方SDK|用戶服務(wù)條款
本網(wǎng)部分資源來源于會員上傳,除本網(wǎng)組織的資源外,版權(quán)歸原作者所有,如有侵犯版權(quán),請立刻和本網(wǎng)聯(lián)系并提供證據(jù),本網(wǎng)將在三個(gè)工作日內(nèi)改正