procedure big_sub(a:stringb:string)
var i,j,k,n:integer
begin
i:=length(a)
j:=length(b)
while (i>=1)and(j>=1) do
begin
if a[i]>=b[j] then k:=0 else k:=10
a[i]:=chr(ord('0')+ord(a[i])+k-ord(b[j]))
n:=i-1
while k>0 do
begin
if a[n]>'0' then k:=0 else k:=10
a[n]:=chr(ord(a[n])+k-1)
n:=n-1
end
i:=i-1
j:=j-1
end
writeln(a)
end
var a,b:string
begin
a:='9999999999999999999999999999999999999'{readln(a)}
b:='9999999999999'{readln(b)}
big_sub(a,b)
a:='1000000000000000000000000000000000000'{readln(a)}
b:='123' {readln(b)}
big_sub(a,b)
end.
程序运行结果是:
9999999999999999999999990000000000000
0999999999999999999999999999999999877
如果要求取消输出结果最左边的0,我相信你也是能做到的。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)