Function check(s1 As Single, n As Single, x) As Single
Dim s2 As Single
Dim rank As Single
For s2 = 1 To 9
For rank = 1 To 3
c1 = c(s1, s2) + x(s1, s2, n, rank) * h
Next
Next
check = 1
End Function
Private Sub Command1_Click()
Dim s2 As Single
Dim m As Single
Dim th1(1 To 100) As Single
Dim th2(1 To 100) As Single
Dim y1(1 To 10, 1 To 10) As Single
Dim y2(1 To 10, 1 To 10) As Single
Dim c(1 To 10, 1 To 10) As Single
Dim x(1 To 10, 1 To 10, 1 To 100, 1 To 3) As Single
Dim s1 As Single
Dim rank As Single
Dim s As Single
Dim r1 As Single
Dim x1 As Single
For s = 1 To 10
th1(s) = 0.2 * s
th2(s) = 0.1 * s
Next
Open "c:/lupin.txt" For Input As #2
Do Until EOF(2)
Input #2, a1, a2, a3, a4, a5
s1 = a1
s2 = a2
c(s1, s2) = a3
y1(s1, s2) = a4
y2(s1, s2) = a5
Loop
Close #2
s1 = 5
t1 = 0
n = 1
Do Until t1 > 100
For s2 = 1 To 10
For rank = 1 To 3
Randomize
r1 = Rnd()
x1 = 0
If r1 > 0.7 Then x1 = 1
If r1 < 0.3 Then x1 = -1
x(s1, s2, n, rank) = x1
Next
Next
sum1 = 0
For s2 = 1 To 10
sum1 = sum1 + x(s1, s2, n, 1) - x(s1, s2, n, 2) - x(s1, s2, n, 3)
Next
If sum1 = 0 Then t1 = 1000
Debug.Print t1, sum1
t1 = t1 + 1
Loop
For s2 = 1 To 10
For rank = 1 To 3
Debug.Print s2, rank, x(s1, s2, n, rank)
Next
Next
Debug.Print check(5, 1, x)
End Sub
最終更新:2009年10月23日 11:06