VB中求下面方程x+2y+3z=40的正整数解.的代码

来源:学生作业学帮网 编辑:学帮网 时间:2024/05/31 20:39:15

VB中求下面方程x+2y+3z=40的正整数解.的代码

正整数解太多了,应该求一定范围的
定义在一百范围,maxint=100吧
用x,y,z三个for 循环实现
for x=1 to maxint
for y=1 to maxint
for z=1 to maxinto
if x+2y+3z=40 then
print x&"-"&y&"-"&z
end if
next z
next y
next x