高精度数的定义:
type
hp=array[1..maxlen] of integer;
1.高精度加法
procedure plus ( a,b:hp; var c:hp);
var i,len:integer;
第1题:
高精度乘以高精度
procedure high_multiply(a,b:hp; var c:hp}
var i,j,len:integer;
begin
fillchar(c,sizeof(c),0);
for i:=1 to a[0] do
for j:=1 to b[0] do begin
inc(c[i+j-1],a[i]*b[j]);
inc(c[i+j],c[i+j-1] div 10);
c[i+j-1]:=c[i+j-1] mod 10;
end;
len:=a[0]+b[0]+1;
while (len>1) and (c[len]=0) do dec(len);
c[0]:=len;
end;
第2题:
高精度除以高精度
procedure high_devide(a,b:hp; var c,d:hp);
var
i,len:integer;
begin
fillchar(c,sizeof(c),0);
fillchar(d,sizeof(d),0);
len:=a[0];d[0]:=1;
for i:=len downto 1 do begin
multiply(d,10,d);
d[1]:=a[i];
while(compare(d,b)>=0) do {即d>=b}
begin
Subtract(d,b,d);
inc(c[i]);
end;
end;
while(len>1)and(c.s[len]=0) do dec(len);
c.len:=len;
end;
第3题:
下列不是Android的数组资源标签的是
A.<array/>
B.<text-array/>
C.<integer-array/>
D.<string-array/>
第4题:
高精度除以低精度
procedure devide(a:hp;b:longint; var c:hp; var d:longint);
{c:=a div b; d:= a mod b}
var i,len:integer;
begin
fillchar(c,sizeof(c),0);
len:=a[0]; d:=0;
for i:=len downto 1 do begin
d:=d*10+a[i];
c[i]:=d div b;
d:=d mod b;
end;
while (len>1) and (c[len]=0) then dec(len);
c[0]:=len;
end;
第5题:
滑动轴承适用于( )和结构上要求剖分的场合。
A.高速、高精度、重载
B.高速、低精度、重载
C.低速、高精度、轻载
D.低速、高精度、重载
第6题:
5、对于多个输入参数的函数也可以使用递归。下面哪个递归定义是正确的自然数加法?也就是说,对于自然数x,y,plus x y给出x+y。
A.plus :: Int -> Int -> Int plus 0 y = y plus x y = 1 + plus (x-1) y
B.plus :: Int -> Int -> Int plus x 0 = x plus x y = 1 + plus x (y-1)
C.plus :: Int -> Int -> Int plus x y = 1 + plus (x-1) y plus 0 y = y
D.plus :: Int -> Int -> Int plus 0 y = y plus x y = 1 + plus (x-1) (y-1)