可以建立一個方向向量用來存儲氣泡運動的方向(方向值每到一定時間隨機產(chǎn)生),再定義一個表示速度的變量(如果要的是均速運動速度值就不變,否則也可以隨機產(chǎn)生)。再用速度和方向值改變氣泡位置。
四子王網(wǎng)站建設(shè)公司成都創(chuàng)新互聯(lián),四子王網(wǎng)站設(shè)計制作,有大型網(wǎng)站制作公司豐富經(jīng)驗。已為四子王數(shù)千家提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\外貿(mào)網(wǎng)站建設(shè)要多少錢,請找那個售后服務(wù)好的四子王做網(wǎng)站的公司定做!
我可以做個例子(qq:359394386),但分不能太低。
如果五個號碼為數(shù)組元素(1)到(5),正確的排序過程:
對于i = 1至4
對于L = 1到5 - 如果A(L)(L +1)
N = A(L)
A(L),= A(L +1)
(L +1) =
結(jié)束如果下一頁l
接下來,我
能夠到第一臺計算機來驗證結(jié)果,然后分析程序。
試試看:
For?i?=?LBound(moto)?To?UBound(moto)?-?1
For?j?=?LBound(moto)?To?UBound(moto)?-?1?-?i
If?moto(j)??moto(j?+?1)?Then
t?=?moto(j)
moto(j)?=?moto(j?+?1)
moto(j?+?1)?=?t
End?If
Next?j
Next?i
For?i?=?LBound(moto)?To?UBound(moto)
Print?moto(i);
Next?i
Imports System.Text.RegularExpressions
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim x, y As String
x = "4,9,12,15,22,33,44,66,72,84,87,92,96,98,99"
y = "6,8,12,16,24,31,68,71,73,74,81,93,94"
Dim g() As Integer
g = Array.ConvertAll((x "," y).Split(","), New Converter(Of String, Integer)(AddressOf strToint))
System.Array.Sort(g)
Dim g_str() As String
g_str = Array.ConvertAll(g, New Converter(Of Integer, String)(AddressOf IntTostr))
Dim My_text As String = Join(g_str, ",")
My_text = Regex.Replace(My_text, "\b(\w+),(?=\1)\b", "") 'My_text是最終結(jié)果
End Sub
Public Shared Function strToint(ByVal bs As String)
Return CInt(bs)
End Function
Public Shared Function IntTostr(ByVal bs As Integer)
Return CStr(bs)
End Function
End Class
My_text是最終結(jié)果,重復(fù)的12被自動剔除了