阅读下列程序流程图 ,从供选择的答案中找出应该填入 ( )处的字句
,并写在答卷的对应栏内 .
供选择的答案:
(a) 2, 0, -3, 7 (b) 0, -3, 2, 7 (c) -3, 0, 7, 2 (d) 7, 2, 0, -3
(e) 2, 0, -3, -3 (f) -3, 0, 2, 7 (g) 2, 2, 0, -3 (h) 2, 0, 7, -3
设 N=4 ,数组 A 的初值为 2,0,-3,7 (即 A[1]=2,A[2]=0,A[3]=-3,A[4]=7 ).
<1> 程序执行完后, A 的值为 ( ).
<2> 若原流程图中,仅把I)框改为 I->J,则程序执行完后,A的值为( ).
<3> 若原流程图中,仅把III)框改为J:N-1,则程序执行完后,A的值为( ).
<4> 若原流程图中,仅把II)框改为 A[I]->A[J]
A[J]->T
T->A[I]
则程序执行完后, A 的值为 ( ).
试题 2 (15)
阅读下列求 S= X 的流程图, 从供选择的答案中找出应填入 a-g 处的字句.
供选择的答案
1,2: a. 读入X b. 读入S c. 读 入j d. 读入N e. 读入X
3,5: a. i:2 b. i:3 c. i:4 d. i:N e. j:2 f. j:3 g. j:4 h. i:j i. j:N
4: a.S*X ->S b. M*X ->S c. S+M ->S d. S+M ->S e. S+X ->S f. M+X ->S
6,7: a. <= b. < c. = d. >= e. > f. <>
阅读下列 pascal 程序, 把应该填入_______处的字句写在答卷的对应栏内.
试题3 ( 15分 )
[程序的说明] 本程序以如下格式打印杨辉三角形 (又称pascal三角形 )的前10行.
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
1 6 15 20 15 6 1
[程序]
program pascaltriangle (output);
const lastrow = 10;
var row,col:2..lastrow;
fe:1..lastrow;
pascal: array [1..lastrow] of integer;
begin pascal[1] := 1;
writeln (pascal[1]);
for row := 2 to lastrow do
begin pascal[row] := 1;
for col := _________ do
pascal[col] := pascal[_______] + pascal[_______];
for fe := 1 to _______ do
write (pascal[fe]);
__________
end
end.
试题 4 (20分)
[程序的说明] 本程序用来打印读入的正文, 并统计和打印该正文中所包含的行,
句和字的数目以及娒扛鲎帜赋鱿值钠刀*. 规定句号(.)作为句子的结束, 不作它
用 ; 字仅由字母组成且每个字不跨行.
[程序]
program textprocess (input,output);
var ch: char; g: boolean; i: integer;
letter: array [`A'..`Z'] of integer;
begin g:=false;
for ch:=`A' to `Z' do letter [ch]:=0;
wordnum:=0; sentencenum:=0;
linenum:=0;
read (ch);
while not eof do
if not eoln then
if ________ then
begin while (ch >= _______ ) and (ch <=_______ )do
begin write (ch);
letter [ch] := letter[ch] + 1;
____________ ;
g := true
end;
if g then
begin ___________;
wordnum := wordnum + 1
end
else begin write (ch); read (ch)
end
end
___________ begin _________________________ ;
write (ch); read (ch)
end
else begin _________________________ ;
writeln; read (ch)
end;
writeln; writeln;
writeln (`linenum = ' , linenum);
writeln (`sentencenum = ' , sentencenum);
writeln (`wordnum = ' , wordnum);
for ch:=______ to ______ do
writeln (ch:3,`:',letter[ch] :6);
writeln
end.
试题 5 ( 25分 )*
[程序的说明] 读入一串整数, 按递增次序枸成一个二叉树.例如: 对以下八个数:
97, -426, 278, 9, -627, 301, 156, 98 构成如右图所示的二叉树.
[程序]
program binarytree (input,output);
type trees = ^boxes;
boxes = record value:integer;
left,right:trees
end;
var valofnode: integer;
root: trees
procedure add (int: integer; var t: trees);
begin if t = nil then
begin ________________ ;
with t^ do
begin value := ____________ ;
left := ____________ ;
right := ____________
end
end
else with t^ do
if ___________ then
add(int,left)
else ____________
end; {add}
begin {main program}
root := nil;
repeat read (valofnode);
________________
until eof
end.
延伸阅读
文章来源于领测软件测试网 https://www.ltesting.net/