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!z14g2000cwz.googlegroups.com!not-for-mail From: "isaac2004" Newsgroups: comp.lang.ada Subject: Re: creating an array Date: 14 Feb 2006 13:14:24 -0800 Organization: http://groups.google.com Message-ID: <1139951664.264622.240870@z14g2000cwz.googlegroups.com> References: <1139897171.996297.230070@z14g2000cwz.googlegroups.com> NNTP-Posting-Host: 67.170.5.168 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1139951669 30092 127.0.0.1 (14 Feb 2006 21:14:29 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 14 Feb 2006 21:14:29 +0000 (UTC) In-Reply-To: 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: z14g2000cwz.googlegroups.com; posting-host=67.170.5.168; posting-account=bWy1LAwAAAAtVkasDCH0ykMCBMNd-FcL Xref: g2news1.google.com comp.lang.ada:2892 Date: 2006-02-14T13:14:24-08:00 List-Id: ok to everybody trying to help me thank you i didnt specify enough. i have a program that takes two inputs from prompts, the first number is an integer less than 10. the second number has the amount of digits that the previous number specifies. what i want to do is split the number up into single digits, sort them and out put the min ascending order. here is my code i cant get the split function right with Ada.Text_Io; use Ada.Text_Io; with Ada.Integer_Text_Io; use Ada.Integer_Text_Io; procedure test 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 ---------------------------------------------------------------------------- type Index is Natural range 1 .. 10 type Number is Natural range 000000000 .. 999999999; type Positivearray is array (Index) of Positive; Num1 : Number; Num_Array : Positivearray; Prompt : Index; Numdigit : Number; procedure Split ( N1 : in Number; A : in out Positivearray ) is Temp : Integer := 1; Remain : Number; begin for I in 1..(Prompt - 1) loop Temp := Temp * 10; end loop; for I in Positivearray'range loop A(N1) := Temp rem 10; Remain := Remain rem Temp; Temp := Temp / 10; if Num1(N1) /= 0 then N1 := N1 + 1; end if; end loop; end Split; 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; -- end of ascending procedure begin Put(Item => " Please enter a number with "); Put(Item => Prompt); Put(Item => " or fewer digits: "); New_Line; Get(Item => Num1); New_Line; Split (Num1, Prompt); Sort (Num1, Prompt); New_Line; Put ("The numbers in sorted order are"); New_Line; for I in 1..Prompt loop Put (Num1(I), 0); New_Line; end loop; end test; any help would be greatly appreciated