题型:综合题 题类:常考题 难易度:困难
浙江省温州市新力量联盟2018-2019学年高二下学期信息技术期末联考试卷
Private Sub Command1_Click()
Dim a(1 To 100) As Integer, y(1 To 100) As String
Dim i, j, k, n, c, res As Integer
n = Val(Text1.Text) '数组 y 记录路径上的数字,n 为行数
For i = 1 To n * (n + 1) / 2
a(i) = Int(Rnd *10)
Next i
List1.AddItem Str(a(1))
y(1) = Str(a(1)): s = "": k = 1
For i = 2 To n
For j = 1 To i
x = k + j - 1
s = s + Str(a(x)) + " "
If j = 1 Then
y(x) = y(x - i + 1) + Str(a(x))
a(x) = a(x) + a(x - i + 1)
ElseIf j = i Then
y(x) = y(x - i) + Str(a(x))
a(x) = a(x) + a(x - i)
ElseIf Then
y(x) = y(x - i + 1) + Str(a(x))
a(x) = a(x) + a(x - i + 1)
Else
y(x) = y(x - i) + Str(a(x))
a(x) = a(x) + a(x - i)
End If
Next j
List1.AddItem s
s = ""
Next i
For c = k To k + n - 1
If a(c) > Max Then Max = a(c): res = c
Next c
List1.AddItem "最大和是:" + Str(Max)
List1.AddItem "访问到的数据依次是:" +
End Sub
试题篮