{Problem 1 on the sample final} USES crt, stackADT, stackType; const n = 9; type pointer = ^ node; node = record info : tokenType; next : pointer end; var p1, list, list1, last, temp : pointer; x : tokenType; procedure print( list : pointer ); {pre : pointer at the begining of the list post : pointer at the beginning of the list again and list printed} var p : pointer; begin p := list; while p <> nil do begin write( p^. info: 3); p := p^.next end; end; procedure copy (list : pointer; var list1 : pointer ); {Copies a list so that the nodes in the copied list are in reverse order. pre : at least a nil node on the list post : the copied list has the nodes in reverse order} var s:stack_obj; x:tokenType; last, q, p:pointer; begin s.init; if list = nil then list1 := nil else begin p := list; while p <> nil do begin {push the original list onto the stack} s.push( p^.info); p := p^.next end {while}; new( p ); list1 := p; while not s.empty do begin p^.info := s.pop; last := p; new( q ); p^.next := q; p := q end; last^.next := nil end {else} end {copy}; begin {build linked list} clrscr; writeln(' type your data'); new( list ); temp := list; while not eoln do begin read( x ); temp^.info := x; last := temp; new( p1 ); temp^.next := p1; temp := p1 end; last^.next := nil; writeln(' The original list is: '); print( list ); writeln; copy( list, list1 ); writeln(' The copied list'); print( list1 ) end.