标题:大数加法运算,结果出现问题,出现星号。请教问题在哪里?
取消只看楼主
TheMask
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2013-3-11
结帖率:100%
已结贴  问题点数:20 回复次数:0 
大数加法运算,结果出现问题,出现星号。请教问题在哪里?
clear
dime x46 (46),y46(46),s46(46)
for i=1 to 46
x46(i)=0
y46(i)=0
s46(i)=0
endfor
accept'请输入加数:'to x
accept'请输入被加数:'to y
for i=1 to int(len(x)/5)+1
x46(i)=val(right(x,5))
x=subst(x,1,len(x)-5)

endfor
for i=1 to int(len(y)/5)+1
y46(i)=val(right(y,5))
y=subst(y,1,len(y)-5)

endfor
for i=1to 46
s46(i)=x46(i)+y46(i)                                          
if s46(i)>=460000
s46(i+1)=val(subst(allt(str(s46(i))),1,len(allt(str(s46(i))))-5))
s46(i+1)=val(right(allt(str(s46(i))),1,5))
endif
endfor
wait
y=''
for i=46 to 1 step-1
if s46(i)>0
y=y+str(s46(i),5)
endif
endfor
? y

加数:12345678901234567890
被加数:12345678901234567890
结果:24690****24690****
2014-03-04 20:47



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-428012-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.053271 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved