题型:填空题 题类:常考题 难易度:困难
浙江省名校协作体2019届高三上学期信息技术9月联考试卷
实现上述功能的VB程序如下,但划线部分代码有错,请改正。
Private Sub Command1_Click()
Dim x(1 To 100) As Single, y(1 To 100) As Single
Dim tmp As Single, length As Single, sum As Single, x1 As Single, y1 As Single
Dim i As Integer, j As Integer, k As Integer
Randomize
List1.Clear
k = Val(Text1.Text)
For i = 1 To k
x(i) = Int(Rnd * 90) / 10 + 1
y(i) = Int(Rnd * 90) / 10 + 1
List1.AddItem "X:" + Str(x(i)) + " " + "Y:" + Str(y(i))
Next i
For i = 1 To k - 1
For j = 1 To k - i
If x(j) > x(j + 1) Then
x(i)=x(i) + x(j)
x(j) = x(i) - x(j)
x(j) = x(i) + x(j) ‘①
tmp = y(j)
y(j) = y(j + 1)
y(j + 1) = tmp
End If
Next j
Next i
sum = 0: length = 0
For i = 1 To k - 1
x1 = (x(i) - x(1)) ^ 2 ‘②
'变量y1计算方法同x1,代码略
length = Sqr(x1 + y1)
sum = sum + length
Next i
Text2.Text = Str(Int(sum * 10) / 10)
End Sub
① ②
试题篮