( ?。?/div>
For i=1 To n
a(i)=①
Int(Rnd*90)+10
Int(Rnd*90)+10
’產(chǎn)生兩位隨機(jī)正整數(shù)
List1.AddItem Str(a(i))
Next i
End Sub
Private Sub Command1_Click
( )
( ?。?/div>
Dim p As Integer,q As Integer,pos1 As Integer,pos2 As Integer,t As Integer
p=1:q=n
Do While ②
p<q
p<q
If a(p)<=a(p+1)Then
pos1=p:pos2=p+1
Else
pos1=p+1:pos2=p
End If
For i=
If a(i)<a(pos1)Then
pos2=pos1
pos1=i
ElseIf a(i)<a(pos2)Then
pos2=i
End If
Next i
If pos1<>p Then t=a(pos1):a(pos1)=a(p):a(p)=t
If pos2=p Then ③
pos2=pos1
pos2=pos1
If pos2<>q Then t=a(pos2):a(pos2)=a(q):a(q)=t
p=p+1:q=q-1
Loop
For i=1 To n
List2.AddItem Str(a(i))
Next i
End Sub
【答案】4;( );Int(Rnd*90)+10;( ?。籶<q;pos2=pos1
【解答】
【點(diǎn)評(píng)】
聲明:本試題解析著作權(quán)屬菁優(yōu)網(wǎng)所有,未經(jīng)書面同意,不得復(fù)制發(fā)布。
發(fā)布:2024/6/27 10:35:59組卷:0引用:1難度:0.5