|
楼主 |
发表于 2012-5-14 13:58
|
显示全部楼层
本帖最后由 香川群子 于 2012-5-14 14:09 编辑
chenzyyysl 发表于 2012-5-14 09:15
Sub sss()
Dim d As Integer, n As Integer, h As Integer, i As Integer
i = 1
挑个毛病:
运行结果,少了一组合理解:男 20人,女 0人,小孩 80人。
代码循环,应该从0开始。
- Sub kagawa()
- Dim d%, n%, h%, j%
- [a1:c1] = Array("d(4)", "n(2)", "h(1/4)")
- i = 1
- For d = 0 To 100
- For n = 0 To 100 - d
- h = 100 - d - n
- If d * 4 + n * 2 + h / 4 = 100 Then '已经定义数据类型为整数变量了,所以不需要ABS误差判断。
- i = i + 1
- Cells(i, 1) = d
- Cells(i, 2) = n
- Cells(i, 3) = h
- End If
- Next
- Next
- End Sub
复制代码
|
|