下列程序段的输出结果为______。
Dim S1(5)As Integer,S2(5)As Integer,S3(5)As Integer
N=4
ForI=1 To N
S1(I)=I
L=N+i-I
S2(I)=L
NextI
S3(5)=0
ForK=1 To N
S3(K)=S1(K)*S2(K)
S3(5)=S3(5)+S3(K)
NextK
PrintS1(3)=S1(5);S1(2)
PrintS2(4)=S3(
第1题:
素数的求法
A.小范围内判断一个数是否为质数:
function prime (n: integer): Boolean;
var I: integer;
begin
for I:=2 to trunc(sqrt(n)) do
if n mod I=0 then begin
prime:=false; exit;
end;
prime:=true;
end;
第2题:
排列的生成:(1..n)
procedure solve(dep:integer);
var
i:integer;
begin
if dep=n+1 then begin writeln(s);exit; end;
for i:=1 to n do
if not used[i] then begin
s:=s+chr(i+ord(''0''));used[i]:=true;
solve(dep+1);
s:=copy(s,1,length(s)-1); used[i]:=false;
end;
end;
第3题:
11、下面哪些定义是类型正确的?
A.f :: (Integer, Integer) -> Float f (x,y) = x / y
B.f :: (Integer, Integer) -> Float f (x,y) = (fromInteger x) / (fromInteger y)
C.f :: (Integer, Integer) -> Float f (x,y) = 3*x + y
D.f :: (Integer, Integer) -> Integer f (x, y) = 3*x + y
第4题:
已知前序后序求中序的一种
function ok(s1,s2:string):boolean;
var i,l:integer; p:boolean;
begin
ok:=true;
l:=length(s1);
for i:=1 to l do begin
p:=false;
for j:=1 to l do
if s1[i]=s2[j] then p:=true;
if not p then begin ok:=false;exit;end;
end;
end;
procedure solve(pre,post:string);
var i:integer;
begin
if (pre='''') or (post='''') then exit;
i:=0;
repeat
inc(i);
until ok(copy(pre,2,i),copy(post,1,i));
solve(copy(pre,2,i),copy(post,1,i));
midstr:=midstr+pre[1];
solve(copy(pre,i+2,length(pre)-i-1),copy(post,i+1,length(post)-i-1));
end;
第5题:
8、下面哪些是将分数化为浮点数的正确定义?
A.type Fraction = (Integer, Integer) rateq :: Fraction -> Float rateq (a,b) = a/b###SXB###B.type Fraction = (Integer, Integer) rateq :: Fraction -> Float rateq (a,b) = (fromInteger a)/ (fromInteger b)###SXB###C.type Fraction = (Integer, Integer) rateq :: Fraction -> Float rateq (a,b) = fromInteger (a/b)###SXB###D.type Fraction = (Integer, Integer) rateq :: Fraction -> Float rateq (a,b) = (fromIntegral a)/ (fromIntegral b)###SXB###E.ty