大学VB考试,特来跪求大神解答啊,谢谢啦
13、给数组任意输入10个整数,然后寻找数组中最小值,将最小值和数组中的第一个元素交换,并保证其余元素不变,最后使用print输出交换前数组的所有元素值和交换后数组的所有元素值。要求在窗口的单击事件书写代码 展开
第12题:
Private Sub Form_Click()
Dim a(1 To 10) As Single
For i = 1 To 10
a(i) = InputBox("No_" & i & "=", "Input Box")
Next i
Print "原数组:";
For i = 1 To 10
Print a(i);
Next i
For i = 1 To 10
For j = 1 To 10 - 1
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
Print "排序后:";
For i = 1 To 10
Print a(i);
Next i
End Sub
第13题:
Private Sub Form_Click()
Dim a(1 To 10) As Integer
For i = 1 To 10
a(i) = InputBox("No_" & i & "=", "Input Box")
Next i
Print "原数组:";
For i = 1 To 10
Print a(i);
Next i
intMin = a(1)
ID = 1
For i = 2 To 10
If a(i) < intMin Then
intMin = a(i)
ID = i
End If
Next i
If ID <> 1 Then
t = a(1)
a(1) = a(ID)
a(ID) = t
End If
Print "交换后:";
For i = 1 To 10
Print a(i);
Next i
End Sub