English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
所有分類

小弟我之前有問過類似的問題所以有些題目都解決掉了,但是現在又碰上了一個更棘手的問題麻煩大大們幫忙了,問題是這樣的:
1.有10個X設為X1~X10,而這10個X裡面又含有25個Q設為Q0~Q24
2.而其中Q0和Q24同樣都是140.5
3.中間的Q1~Q23求法是這樣的:舉Q0和Q1的關係當例子
Q1min=Q0+17.8*3600/1000000-25.2*3600/1000000
Q1max=Q0+17.8*3600/1000000
所以Q1的值要介於Q1min~Q1max之間取亂數,做完了換Q2
Q2min=Q1+17.8*3600/1000000-25.2*3600/1000000
Q2max=Q1+17.8*3600/1000000
所以Q2的值要介於Q2min~Q2max之間取亂數,以此類推
所以印出來的結果希望是這樣:
X1=[140.5 ............................................140.5]
X2=[140.5.............................................140.5]一直到
X10=[140.5............................................140.5]中間的點點點代表Q1~Q23求出來的值
希望這樣寫大大們會看的很清楚,麻煩VB高手大大貼程式碼上去了!小弟我會感激不盡!!

2006-09-25 15:47:50 · 3 個解答 · 發問者 亮晶晶NO.1 1 in 電腦與網際網路 程式設計

3 個解答

Private Sub Command1_Click()   Cls   Me.FontName = "細明體"   Dim X(10) As String, Q(24) As Single   For i = 1 To 10      For j = 0 To 24            'Q0與Q24的例外處理         If j = 0 Or j = 24 Then            Q(j) = 140.5         Else            Randomize            'Qj_Min = Qj-1_Min + ...            tmpMin = Q(j - 1) + 17.8 * 3600 / 1000000 - 25.2 * 3600 / 1000000                        'Qj_Max = Qj-1_Max + ...            tmpMax = Q(j - 1) + 17.8 * 3600 / 1000000                        'Qj = tmpMin與tmpMax間取亂數            Q(j) = (Rnd * (tmpMax - tmpMin + 1)) + tmpMin         End If         X(i) = X(i) & Q(j) & IIf(j < 24, ",", "")      Next      Print "X" & i; "=["; X(i); "]"   NextEnd Sub

2006-09-25 20:31:58 · answer #1 · answered by ? 6 · 0 0

Private Sub Command1_Click()    Dim X(1 To 10), I As Integer, J As Integer        Const Max = 17.8 * 3600 / 1000000    Const Min = (17.8 - 25.2) * 3600 / 1000000    Cls    For I = 1 To 10        X(I) = Split(String(24, " "))        X(I)(0) = 140.5: X(I)(24) = 140.5        Randomize        For J = 1 To 23            X(I)(J) = Rnd * (Max - Min + 1) + Min + X(I)(J - 1)        Next        Print "X"; CStr(I); "=["; Join(X(I), ","); "]"    NextEnd Sub

2006-09-25 22:01:50 · answer #2 · answered by W.J.S. 7 · 0 0

先把你想到的解法,不管對錯,寫出來再說。

2006-09-25 16:36:25 · answer #3 · answered by Phoenix 5 · 0 0

fedest.com, questions and answers