2019-04-13
你自己打开看看!
代码在下面:
Option Explicit
Private Sub Command1_Click()
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim Y As Integer
Dim n69 As Integer
Dim n39 As Integer
Dim n29 As Integer
Y = 600
For i = 1 To 8 '设截取69CM的有i根,600/69 最多为8
For j = 1 To 15 '设截取39CM的有J根,600/39 最多为15
For k = 1 To 20 '设截取29CM的有K根,600/29 最多为20
If i * 69 + j * 39 + k * 29 <= 600 Then '如果满足不超过600CM的,就是一组答案
If 600 - (i * 69 + j * 39 + k * 29) < Y Then '如果余数比变量Y里的小,就保存i,j,k以及余数
n69 = i
n39 = j
n29 = k
Y = 600 - (i * 69 + j * 39 + k * 29)
End If
End If
Next k
Next j
Next i
Print "69CM:"; n69; "根"
Print "39CM:"; n39; "根"
Print "29CM:"; n29; "根"
Print "余:"; Y; "CM"
End Sub
Private Sub Command2_Click()
Dim i As Integer
For i = 0 To 99 '把这两位看作一个两位数字,范围是0-99
'注意要乘以10,充当5位数字的十位和百位,mod 等于0,表示能整除
If (67008 + 10 * i) Mod 78 = 0 And (67008 + 10 * i) Mod 67 = 0 Then
Print 67008 + 10 * i
End If
Next i
End Sub
你自己打开看看!
代码在下面:
Option Explicit
Private Sub Command1_Click()
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim Y As Integer
Dim n69 As Integer
Dim n39 As Integer
Dim n29 As Integer
Y = 600
For i = 1 To 8 '设截取69CM的有i根,600/69 最多为8
For j = 1 To 15 '设截取39CM的有J根,600/39 最多为15
For k = 1 To 20 '设截取29CM的有K根,600/29 最多为20
If i * 69 + j * 39 + k * 29 <= 600 Then '如果满足不超过600CM的,就是一组答案
If 600 - (i * 69 + j * 39 + k * 29) < Y Then '如果余数比变量Y里的小,就保存i,j,k以及余数
n69 = i
n39 = j
n29 = k
Y = 600 - (i * 69 + j * 39 + k * 29)
End If
End If
Next k
Next j
Next i
Print "69CM:"; n69; "根"
Print "39CM:"; n39; "根"
Print "29CM:"; n29; "根"
Print "余:"; Y; "CM"
End Sub
Private Sub Command2_Click()
Dim i As Integer
For i = 0 To 99 '把这两位看作一个两位数字,范围是0-99
'注意要乘以10,充当5位数字的十位和百位,mod 等于0,表示能整除
If (67008 + 10 * i) Mod 78 = 0 And (67008 + 10 * i) Mod 67 = 0 Then
Print 67008 + 10 * i
End If
Next i
End Sub