const
max=1000;
var
a,b:array[0..max]of longint;
procedure init;
var
s1,s2,s:string;
l1,l2,i:longint;
begin
readln(s1);
readln(s2);
l1:=length(s1);
l2:=length(s2);
if (l2>l1)or(l1=l2)and(s1<s2) then
begin
write('-');
s:=s1;s1:=s2;s2:=s;
l1:=length(s1);
l2:=length(s2);
end;
for i:=1 to l1 do
a[max-l1+i]:=ord(s1[i])-ord('0');
for i:=1 to l2 do
b[max-l2+i]:=ord(s2[i])-ord('0');
end;
procedure jf;
var
g,i:longint;
begin
g:=0;
for i:=max downto 1 do
if a[i]>=b[i]+g then
begin
a[i]:=a[i]-b[i]-g;
g:=0;
end else
begin
a[i]:=a[i]+10-b[i]-g;
g:=1;
end;
end;
procedure print;
var
i,j:longint;
begin
i:=1;
while (i<max)and(a[i]=0) do inc(i);
for j:=i to max do
write(a[j]);
end;
begin
init;
jf;
print;
end.
高精度减法pascal程序
最新推荐文章于 2018-01-28 19:51:06 发布