VB编程,求步骤有一根长度为546米的钢材料,要将它截取成两种规格a、b的长度分别为19米和28米的短料,每种至少1段,问分隔成a,b各多少段后,剩余的残料r最少?编程解决此计算问题.
来源:学生作业帮助网 编辑:六六作业网 时间:2025/02/01 04:57:41
VB编程,求步骤有一根长度为546米的钢材料,要将它截取成两种规格a、b的长度分别为19米和28米的短料,每种至少1段,问分隔成a,b各多少段后,剩余的残料r最少?编程解决此计算问题.
VB编程,求步骤
有一根长度为546米的钢材料,要将它截取成两种规格a、b的长度分别为19米和28米的短料,每种至少1段,问分隔成a,b各多少段后,剩余的残料r最少?编程解决此计算问题.
VB编程,求步骤有一根长度为546米的钢材料,要将它截取成两种规格a、b的长度分别为19米和28米的短料,每种至少1段,问分隔成a,b各多少段后,剩余的残料r最少?编程解决此计算问题.
'19米14,28米10,剩余0 加个text,设为多行显示Text1.MultiLine = True
Private Sub Command1_Click()
Dim tmp As Variant
Dim tmp1 As Single, tmp2 As Single, s_tp As String
Dim tmp3 As Variant
Dim s1 As String, ss As String, l_tp As Single
Dim i As Long, l As Long, x As Long, k1 As Long, k2 As Long, k3 As Long, k4 As Long, kk As Long
kk = 546
k1 = 19
k2 = 28
k3 = kk \ k1k4 = kk \ k2
For i = 1 To k3
For l = 1 To k4
l_tp = i * k1 + l * k2
If l_tp tmp2 Then
s_tp = tmp(i)
tmp(i) = tmp(x)
tmp(x) = s_tp
End If
Next
Next
Print tmp(UBound(tmp))
ss = k1 & "米," & k2 & "米," & "剩余"
For i = UBound(tmp) To 0 Step -1
ss = ss & vbCrLf & tmp(i)
' Print tmp(i)
Next
Text1.Text = ss
MsgBox "利用率最高的方法是" & tmp(UBound(tmp))
End Sub