pascal高精度加减乘除?

来源:百度知道 编辑:UC知道 时间:2024/05/16 08:04:07

第二章 高精度计算

2.1 高精度加法
2.2 高精度减法
2.3 高精度乘法

2.4 高精度除法

2.1高精度加法

高精度加法程序如下:

program HighPrecision1_Plus;
const
fn_inp='hp1.inp';
fn_out='hp1.out';
maxlen=100; { max length of the number }
type
hp=record
len:integer; { length of the number }
s:array[1..maxlen] of integer
{ s[1] is the lowest position
s[len] is the highest position }
end;
var
x:array[1..2] of hp;
y:hp; { x:input ; y:output }

procedure PrintHP(const p:hp);
var i:integer;
begin
for i:=p.len downto 1 do write(p.s[i]);
end;

procedure init;
var
st:string;
j,i:integer;
begin
assign(input,fn_inp);
reset(input);
for j:=1 to 2 do
begin
readln(st);
x[j].len:=length(st);
for i:=