
VB中求下面方程x+2y+3z=40的正整数解。的代码
1个回答
展开全部
正整数解太多了,应该求一定范围的
定义在一百范围,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
定义在一百范围,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
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询