计算机类

高精度数的定义:typehp=array[1..maxlen] of integer;1.高精度加法procedure plus ( a,b:hp; var c:hp);var i,len:integer;

题目

高精度数的定义:

type

hp=array[1..maxlen] of integer;

1.高精度加法

procedure plus ( a,b:hp; var c:hp);

var i,len:integer;

如果没有搜索结果,请直接 联系老师 获取答案。
如果没有搜索结果,请直接 联系老师 获取答案。
相似问题和答案

第1题:

高精度减法

procedure substract(a,b:hp;var c:hp);

var i,len:integer;


正确答案:

 

begin
fillchar(c,sizeof(c),0);
if a[0]>b[0] then len:=a[0] else len:=b[0];
for i:=1 to len do begin
inc(c[i],a[i]-b[i]);
if c[i]<0 then begin inc(c[i],10);dec(c[i+1]); end;
while (len>1) and (c[len]=0) do dec(len);
c[0]:=len;
end;

第2题:

高精度乘以高精度

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;

第3题:

M B G 1 4 3 2属于()。

A.自动高精度万能磨床

B.半自动万能磨床

C.半自动高精度万能磨床

D.半自动高精度磨床


正确答案:C

第4题:

下列不是Android的数组资源标签的是

A.<array/>

B.<text-array/>

C.<integer-array/>

D.<string-array/>


主要放置一些文件资源,这些文件会被原封不动打包到apk里面。

第5题:

高精度除以高精度

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;

第6题:

高精度乘以低精度

procedure multiply(a:hp;b:longint;var c:hp);

var i,len:integer;


正确答案:

 

begin
fillchar(c,sizeof(c),0);
len:=a[0];
for i:=1 to len do begin
inc(c[i],a[i]*b);
inc(c[i+1],(a[i]*b) div 10);
c[i]:=c[i] mod 10;
end;
inc(len);
while (c[len]>=10) do begin {处理最高位的进位}
c[len+1]:=c[len] div 10;
c[len]:=c[len] mod 10;
inc(len);
end;
while (len>1) and (c[len]=0) do dec(len); {若不需进位则调整len}
c[0]:=len;
end;{multiply}

第7题:

高精度除以低精度

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;

第8题:

高精度数的定义:

type

hp=array[1..maxlen] of integer;

1.高精度加法

procedure plus ( a,b:hp; var c:hp);

var i,len:integer;


正确答案:

 

begin
fillchar(c,sizeof(c),0);
if a[0]>b[0] then len:=a[0] else len:=b[0];
for i:=1 to len do begin
inc(c[i],a[i]+b[i]);
if c[i]>10 then begin dec(c[i],10); inc(c[i+1]); end; {进位}
end;
if c[len+1]>0 then inc(len);
c[0]:=len;
end;{plus}

第9题:

滑动轴承适用于( )和结构上要求剖分的场合。

A.高速、高精度、重载

B.高速、低精度、重载

C.低速、高精度、轻载

D.低速、高精度、重载


正确答案:D

第10题:

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)


正确