自考“高级语言程序设计”测试题(3)
问题:构造一链表,并按与输入相同的次序输出该链表中的数据。
程序:
PROGRAM fifolist(input,output);
TYPE
pointer=↑cooperate;
cooperate=RECORD
next:pointer;
data:integer
END;
VAR
p1,p2,p3:pointer;
BEGIN
( ④ );
P3:=P1
read(p1↑。data);
WHILE NOT eof DO
BEGIN
( ⑤ );
read(p2↑。data);
( ⑥ );
p3:=p2
END;
P2↑。next:=NIL;
WHILE P1 NIL DO
GEGIN
write(p1↑。data);
( ⑦ );
END;
END.
4.你选择( )
A.P1:=NIL
B.P2:=NIL
C.NEW(P1)
D.new(p2)
5.你选择( )
A.P1:=NIL
B.P2:=NIL
C.new(P1)
D.new(P2)
6.你选择( )
A.p3↑。next:=P2
B.P3↑。next:=NIL
C.P3↑。next:=P2↑。next
D.p3↑。next:=p3