我正在尝试对多维数组进行排序,但不确定这是否是正确的方法。到目前为止,我在多维数组中获取了我的 5 个数字,然后将它们移动到一维数组中并使用数组排序。知道更好的方法吗?或者对如何改进我的有想法?此外,代码目前在排序区域中不起作用,它给了我一个数组错误的索引。
任何帮助将不胜感激。提前致谢
Module q
Sub Main()
Randomize()
Dim Player,RandomNumber,NumberOfPlayers,Index As Integer
Dim Roll as Integer = 0
Console.Write("How many people will be playing Yahtzed?: ")
Player = convert.toint32(Console.Readline)
NumberOfPlayers = Player
Dim Game(Player,5) As Integer
Do until Player = 0
Console.Write("User")
Roll = 0
Do until Roll = 5
RandomNumber = CINT(Int((6 * Rnd()) + 1))
Game(Player,Roll) = RandomNumber
Roll += 1
Console.Write(" "&RandomNumber)
Loop
Player -= 1
Console.Writeline()
Loop
Player = NumberOfPlayers
Do until Player = 0
Dim Ordering(5) as Integer
Roll = 0
Do until Roll = 5
Ordering(Index) = Game(Player,Roll)
Roll += 1
Index += 1
Array.Sort(Ordering)
Loop
Loop
End Sub
End Module