数字排序问题求教
一列数据,11,33,44,66,114,66,66,22,44,6,77这样无序排列需要将这些数字按行排列,每行3个,请问该怎么做呢
11,33,44
66,114,66
66,22,44
6,77
这样子
求教
Option Explicit Private arr_TestNumber(99) As Integer Private Sub Command1_Click() Dim i As Integer, j As Integer, temp As Integer Randomize For i = 0 To UBound(arr_TestNumber) arr_TestNumber(i) = Rnd * 100 + i Debug.Print arr_TestNumber(i), If i Mod 3 = 2 Then Debug.Print Next '以上代码,给数组的元素赋随机数,只为了测试效果 Debug.Print Debug.Print "=========================================================================" '开始排序 For j = 0 To UBound(arr_TestNumber) - 1 For i = j + 1 To UBound(arr_TestNumber) If arr_TestNumber(j) > arr_TestNumber(i) Then temp = arr_TestNumber(i) arr_TestNumber(i) = arr_TestNumber(j) arr_TestNumber(j) = temp End If Next i Next j '打印排序后的结果 For i = 0 To UBound(arr_TestNumber) Debug.Print arr_TestNumber(i), If i Mod 3 = 2 Then Debug.Print Next End Sub '最后,个人觉得楼主问的问题都是很基础的,建议最好还是把教科书上的例子,看多几遍,直到看懂为止