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.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,3f1374bc66d2dc03 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!f14g2000cwb.googlegroups.com!not-for-mail From: "isaac2004" Newsgroups: comp.lang.ada Subject: Re: creating an array Date: 15 Feb 2006 15:29:08 -0800 Organization: http://groups.google.com Message-ID: <1140046148.803154.70980@f14g2000cwb.googlegroups.com> References: <1139897171.996297.230070@z14g2000cwz.googlegroups.com> <1139951664.264622.240870@z14g2000cwz.googlegroups.com> <1139955455.397334.310790@g43g2000cwa.googlegroups.com> <878xsd8sqq.fsf@ludovic-brenta.org> <1139957691.430522.159580@o13g2000cwo.googlegroups.com> <874q318rkd.fsf@ludovic-brenta.org> <1139960269.338824.166090@g14g2000cwa.googlegroups.com> <87u0b070gl.fsf@ludovic-brenta.org> NNTP-Posting-Host: 67.170.5.168 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1140046154 16043 127.0.0.1 (15 Feb 2006 23:29:14 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 15 Feb 2006 23:29:14 +0000 (UTC) In-Reply-To: <87u0b070gl.fsf@ludovic-brenta.org> User-Agent: G2/0.2 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727),gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: f14g2000cwb.googlegroups.com; posting-host=67.170.5.168; posting-account=bWy1LAwAAAAtVkasDCH0ykMCBMNd-FcL Xref: g2news1.google.com comp.lang.ada:2912 Date: 2006-02-15T15:29:08-08:00 List-Id: hey finally got it to work thanks to everybody for helping. here is code with Ada.Text_Io; use Ada.Text_Io; with Ada.Integer_Text_Io; use Ada.Integer_Text_Io; procedure Lab6 is ----------------------------------------------------------------------------------------------- --| Recieves two inputs, one being a number les than ten and the other number is a number with the same amount of digits --| as the first recieved number. the second number is then seperated, the digits stored in an array and put into ascending order --| Author: Isaac Levin, Western Washington University --| Last Modified: February 2006 ---------------------------------------------------------------------------- subtype Index is Natural range 1 .. 10; subtype Number is Natural range 000000000 .. 999999999; type Positivearray is array (1 .. 10) of Natural; A : Positivearray; Promptnum : Index; Fullnum : Number; procedure Split ( N : in Number; Num_Digits : in Index; Dl : in out Positivearray) is -- set the variables Temp : Natural := 1; Remain : Number := N; Numdigits : Natural := 1; -- set this flag to TRUE initially to signify that we should ignore the leading zeros Leadingzero : Boolean := True; -- Calculate the largest number to divide the input number by so we can extract the left most digit. -- So if # of digits specified are: 3, then Temp would be: 100 begin -- Loop to extract all the digits -- Note: Numdigit is used as the index variable for our array, this helps us take out the leading zeros if the number entered -- has less digits than what the user specified for I in 1..Num_Digits loop -- Get the individual digit by remaindering A(I) := Remain mod 10; -- Store the remainder so in the next loop we can extract the next left most digit Remain := Remain / 10; end loop; end Split; -- procedure to sort parts of array procedure Sort ( Thearray : in out Positivearray; Inuse : in Natural) is -- Sorts the elements of the array from smallest to largest Min : Positive; Indexmin : Positive; Temp : Positive; begin for I in 1..Inuse - 1 loop Min := Thearray(I); Indexmin := I; for J in I + 1 .. Inuse loop if Thearray(J) < Min then Min := Thearray(J); Indexmin := J; end if; end loop; Temp := Thearray(I); Thearray(I) := Min; Thearray(Indexmin) := Temp; end loop; end Sort; begin -- actual interface Put ("Please enter the number of digits."); Get(Item => Promptnum); New_Line; Put(Item => "Please enter a number with ") ; Put ( Item => Promptnum, Width => 0) ; Put (Item => " digits."); Get(Item => Fullnum); Split(Fullnum, Promptnum, A); Sort (A, Promptnum); -- sort array New_Line; Put ("The numbers in sorted order are"); New_Line; for I in 1..Promptnum loop Put (A(I), 0); New_Line; end loop; end Lab6; thank you Happy Coding!