高精度减法
来源:互联网 发布:网络路演 编辑:程序博客网 时间:2024/05/15 07:42
方便调用,直接写成了高精度减法的函数
function gjdjfa(a,b:ansistring):ansistring;var d:ansistring; c:array[1..10000]of ansistring; i,max,m,n,x,y,code,z,right,count1:longint;begin for i:=1 to 10000 do c[i]:='a'; m:=length(a); n:=length(b); for i:=1 to m do if pos(' ',a)<>0 then delete(a,pos(' ',a),1); for i:=1 to n do if pos(' ',b)<>0 then delete(b,pos(' ',b),1); m:=length(a); n:=length(b); if m>n then begin max:=m; for i:=1 to m-n do b:='0'+b; end else if m<n then begin max:=n; for i:=1 to n-m do a:='0'+a; end else max:=m; for i:= 1 to max do begin val(a[max-i+1],x,code); val(b[max-i+1],y,code); if max=n then begin count1:=y-x-z; right:=1;end else count1:=x-y-z ;if count1>=0 then begin str(count1,c[i]); z:=0;end else begin str(count1+10,c[i]); z:=1; end; end; for i:=10000 downto 1 do begin if c[i]='a' then d:=d else d:=d+c[i]; end; if right=1 then d:='-'+d; if( m-n>0)and (copy(d,1,1)='0') then delete(d,1,m-n); exit(d);end;
0 0
- 高精度减法
- 高精度减法
- 高精度减法
- 高精度减法
- 高精度减法
- 高精度减法
- 高精度减法
- 高精度减法
- 高精度减法
- 高精度减法
- 高精度减法
- 高精度减法
- 高精度减法
- 高精度减法
- 高精度减法
- 高精度减法
- 高精度减法
- 高精度减法
- ZooKeeper的示例代码
- VS2010 中“无法直接启动带有类库输出类型的项目”解决方案
- asp.net 学习之路之gridView控件
- apt linux命令简介
- 如何区分Oracle的数据库,实例,服务名,SID
- 高精度减法
- cxf的spring启动测试配置
- 插入排序Insertion Sort
- 2-SAT问题的解法(uva1146)
- git简单使用入门总结
- MVC 模式中正向传值、反向传值
- malloc函数应用
- putty免密码实现自动登录远程主机
- 正负数排序