我正在尝试以编程方式在方程式146 + x + y 除以 7 = 28.13% x 中找到 x 和 y 的值,并且 y 包含 19 到 43 之间的任何值。这是我得到的 x 和 y 均为 25 的代码,什么我做错了吗?
Public Class Form1
Dim percentage, x, y, f As Integer
Public Function GetRandom(ByVal Min As Integer, ByVal Max As Integer) As Integer
Dim Generator As System.Random = New System.Random()
Return Generator.Next(Min, Max)
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
percentage = 28.13
Do Until f = 4
If (146 + x + y) / 7 = percentage Then
MessageBox.Show(x)
MessageBox.Show(y)
f = 4
End If
x = GetRandom(19, 43)
y = GetRandom(19, 43)
Loop
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
x = 19
y = 19
End Sub
End Class