From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,e433da2465aede0e,start X-Google-Attributes: gid103376,public From: "bklungle" Subject: Re: Code Confusion. Date: 1997/11/02 Message-ID: <63ivf4$m5@sjx-ixn5.ix.netcom.com>#1/1 X-Deja-AN: 286646346 References: <345CD154.1249E04E@eng.ua.edu> X-MimeOLE: Produced By Microsoft MimeOLE V4.71.1712.3 Organization: B & D Associates X-NETCOM-Date: Sun Nov 02 2:39:32 PM PST 1997 Newsgroups: comp.lang.ada Date: 1997-11-02T14:39:32-08:00 List-Id: At a quick glance, it looks like your code is generating a single node loop on itself (among other things.) Using your constructs, one possible sequence for building a push-down stack linked list of nodes could be as follows: .. .. begin --lab10A -- assuming a use clause was given for text_io (or equivalent) put("Please enter the number of nodes desired "); -- assuming a new and use clause was given for integer_io (or equivalent) get(NUM_NODES); -- get integer number of nodes skip_line; -- make sure no garbage at end of line if NUM_NODES /= 0 then HEAD := new LIST_NODE; put("Please enter integer node value for node 1: "); get(HEAD.NUM); -- get nodes integer value skip_line; -- make sure no garbage at end of line for i in 2 .. NUM_NODES loop P := new LIST_NODE; -- get another dynamic node P.NEXT := HEAD; -- link current head behind this one HEAD := P; -- this is now the current head put("Please enter integer node value for node " & integer'image(i) & " "); get(P.Num); skip_line; -- make sure no garbage at end of line end loop; . . end if; -- Note: This is not the best, or only way to do this, only one quick way. Cheers...bob Supreme wrote in message <345CD154.1249E04E@eng.ua.edu>... >In the following program I am trying to display the values of linked >list instead my output is >80 80 80 80 80 80 >instead of 40 50 60 70 80. >here it is. >procedure problem is > type LIST_NODE; > type NODE_PTR is access LIST_NODE; > type LIST_NODE is record > NUM : INTEGER; > NEXT : NODE_PTR; > end record; > >HEAD,P : NODE_PTR; >N, NUM_NODES : INTEGER; >begin -- lab10A > Put("Please enter the the values of the nodes"); >Get( Num_Nodes); >Head := new NODE; >New_Line; >P := Head; > for K in 2..NUN_NODES loop >Head.Next := P; >P.ALL.NUM := N; >P := P.Next; >end loop; > Will this allow teh user to assing 20 30 40 50 etc to the linked >list? >in other words >Head.Next := P Should point the Head.next to the Pointer P and >then P.ALL.NUM :=N should be set to the value of N ( entered by the >user) >then P := P.Next should allow N to be assigned to the next pointer. >is this right?? >Peace. >