回 帖 发 新 帖 刷新版面

主题:设计一个程序()3*6528=3()*8256在括号中输入一个数使等式成立

cls
for i=1 to 9
if (i*10+3)*6528=(30+i)*8256 then print i
next i
end 

回复列表 (共2个回复)

沙发

对有解的一位数这样做不错。

我来个锦上添花,把无解的情况给也列出来

cls
j=0
for i=1 to 9
if (i*10+3)*6528=(30+i)*8256 then j= i:exit for
next i
if j=0 then 
   print "没有合适的一位数字。"
else
   print "能使等式成立的数字是";j
end if
end 

但是这里还是没有涉及到多位数的情况,还有就是多个合适的数字只能选中一个。

板凳

多位数改成这样就可以了啊
j=0
for i=1 to 9
  if (i*10+3)*6528=(30+i)*8256 then 
    print i
    j=i
  end if
next i
if j=0 then 
   print "没有合适的一位数字。"
end if
end

我来回复

您尚未登录,请登录后再回复。点此登录或注册