Give an array and a certain number,how to select some of the elements to sums upto the number? (Also see
http://blog.csdn.net/northwolves/archive/2008/11/25/3372338.aspx)
The following codes can bring you solutions out in Column A of Excel worksheet :
It returns:
| 1+10+11+12+12+13+14+15=88 |
| 1+10+11+15+16+17+18=88 |
| 1+10+12+14+16+17+18=88 |
| 1+10+12+14+16+17+18=88 |
| 1+10+13+14+15+17+18=88 |
| 1+11+12+13+16+17+18=88 |
| 1+11+12+13+16+17+18=88 |
| 1+11+12+14+15+17+18=88 |
| 1+11+12+14+15+17+18=88 |
| 1+11+13+14+15+16+18=88 |
......
Total 8528 solutions within about 3 seconds.

本文介绍了一个使用VBA在Excel中实现的数独解决方案。通过递归算法,该程序能够找到给定数组中元素组合,使其总和等于指定数值。演示案例为寻找多个数字组合相加等于88的情况。

3万+

被折叠的 条评论
为什么被折叠?



