pascal高精度

来源:百度知道 编辑:UC知道 时间:2024/09/25 08:21:51
① 越精简越好
② 是要函数function
③ 数组读入数组读出
④ 加减乘除都要
做得好的追加30分
只要函数function
还要有文件读入输出

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:=1 to x[j].len do { change string to HP }
x[j].s[i]:=ord(st[x[j].len+1-i])-ord(&#