EXCEL中求解:例如:11*A+21*B+31*C+41*D+51*E=500(求和接近500即可),如何找出符合AB
来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/22 12:49:29
EXCEL中求解:例如:11*A+21*B+31*C+41*D+51*E=500(求和接近500即可),如何找出符合ABCDE的各种组合?
其中ABCD为自然数.
实际问题是这样的:单次发货固定总金额为500元,现有200种价格不同产品进行搭配发货(单价均低于500),求符合条件的各种组合.
其中ABCD为自然数.
实际问题是这样的:单次发货固定总金额为500元,现有200种价格不同产品进行搭配发货(单价均低于500),求符合条件的各种组合.
用VBA编程,例如在一个空白表编制如下命令按钮程序(我使用的是2007版,运行约45秒):
Private Sub CommandButton1_Click()
Const zj = 500
Dim dj2 As Double,dj3 As Double,dj4 As Double,dj5 As Double,dj6 As Double,s As Double
Dim i2 As Integer,i3 As Integer,i4 As Integer,i5 As Integer,i6 As Integer,j As Integer
Range("A:XFD").ClearContents
Range("A1:B1") = Array("品名","单价")
Range("A2:B2") = Array("A",11)
Range("A3:B3") = Array("B",21)
Range("A4:B4") = Array("C",31)
Range("A5:B5") = Array("D",41)
Range("A6:B6") = Array("E",51)
dj2 = Range("B2")
dj3 = Range("B3")
dj4 = Range("B4")
dj5 = Range("B5")
dj6 = Range("B6")
j = 3
For i6 = 0 To zj \ dj6
For i5 = 0 To (zj - dj6 * i6) \ dj5
For i4 = 0 To (zj - dj6 * i6 - dj5 * i5) \ dj4
For i3 = 0 To (zj - dj6 * i6 - dj5 * i5 - dj4 * i4) \ dj3
Cells(3,j) = i3
Cells(4,j) = i4
Cells(5,j) = i5
Cells(6,j) = i6
s = dj3 * i3 + dj4 * i4 + dj5 * i5 + dj6 * i6
i2 = Round((zj - s) / dj2,0)
Cells(2,j) = i2
Cells(7,j) = dj2 * i2 + s
j = j + 1
Next i3
Next i4
Next i5
Next i6
部分计算结果如下:
品名\x05单价\x05\x05\x05\x05\x05\x05\x05\x05
A\x0511\x0545\x0544\x0542\x0540\x0538\x0536\x0534\x0532
B\x0521\x050\x051\x052\x053\x054\x055\x056\x057
C\x0531\x050\x050\x050\x050\x050\x050\x050\x050
D\x0541\x050\x050\x050\x050\x050\x050\x050\x050
E\x0551\x050\x050\x050\x050\x050\x050\x050\x050
\x05\x05495\x05505\x05504\x05503\x05502\x05501\x05500\x05499
Private Sub CommandButton1_Click()
Const zj = 500
Dim dj2 As Double,dj3 As Double,dj4 As Double,dj5 As Double,dj6 As Double,s As Double
Dim i2 As Integer,i3 As Integer,i4 As Integer,i5 As Integer,i6 As Integer,j As Integer
Range("A:XFD").ClearContents
Range("A1:B1") = Array("品名","单价")
Range("A2:B2") = Array("A",11)
Range("A3:B3") = Array("B",21)
Range("A4:B4") = Array("C",31)
Range("A5:B5") = Array("D",41)
Range("A6:B6") = Array("E",51)
dj2 = Range("B2")
dj3 = Range("B3")
dj4 = Range("B4")
dj5 = Range("B5")
dj6 = Range("B6")
j = 3
For i6 = 0 To zj \ dj6
For i5 = 0 To (zj - dj6 * i6) \ dj5
For i4 = 0 To (zj - dj6 * i6 - dj5 * i5) \ dj4
For i3 = 0 To (zj - dj6 * i6 - dj5 * i5 - dj4 * i4) \ dj3
Cells(3,j) = i3
Cells(4,j) = i4
Cells(5,j) = i5
Cells(6,j) = i6
s = dj3 * i3 + dj4 * i4 + dj5 * i5 + dj6 * i6
i2 = Round((zj - s) / dj2,0)
Cells(2,j) = i2
Cells(7,j) = dj2 * i2 + s
j = j + 1
Next i3
Next i4
Next i5
Next i6
部分计算结果如下:
品名\x05单价\x05\x05\x05\x05\x05\x05\x05\x05
A\x0511\x0545\x0544\x0542\x0540\x0538\x0536\x0534\x0532
B\x0521\x050\x051\x052\x053\x054\x055\x056\x057
C\x0531\x050\x050\x050\x050\x050\x050\x050\x050
D\x0541\x050\x050\x050\x050\x050\x050\x050\x050
E\x0551\x050\x050\x050\x050\x050\x050\x050\x050
\x05\x05495\x05505\x05504\x05503\x05502\x05501\x05500\x05499
EXCEL中求解:例如:11*A+21*B+31*C+41*D+51*E=500(求和接近500即可),如何找出符合AB
在一组数据中要找出符合我条件的数值然后求和,excel里用哪个函数,例如:A B C D 1 4 -2 3 -5
EXCEL中A,B,C,D四列 怎样找出A,C相同值 如找出A1=C10,请问如何确定B1=D10
如何在Excel中找出两列数据中相同的数字并用颜色标注,例如求A列与B列相同的数字并在C列显示,求解?
在EXCEL表格中(共500行省) A B C D E F G ----------------------------
excel,如何把A、B、C、D等中符合条件1的数据加上方表格上,
我在excel表中设置了自动求和公式,比如列E=列A+列B+列C+列D,结果我改了列A中的数列E的数竟然没变化.
求,excel 函数,概率型随机数公式: 例如,a、b、c、d、e之间的随机数.
excel如何提取字符,例如A-B-C-D,ABCD代表着不同的字符串,数目不定,如何从中提取A段B段C段D段
在EXCEL表格中如何找出AB列相同的数,B列中有A列相同的数,找出AB列相同的数并删除,形成新的C列
excel调整列顺序:例如,一个表中有A B C D 四列,如何快速将数据调整为D C B A 排列
exceL怎样设公式让e=c-a或e=d-b