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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,71c743c03ed191fe X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-09-19 23:35:33 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!nntp-server.caltech.edu!attla2!ip.att.net!attbi_feed3!attbi.com!rwcrnsc53.POSTED!not-for-mail From: tmoran@acm.org Newsgroups: comp.lang.ada Subject: Re: Beginer problem: variable array size References: <38993b18.0209191906.b56b982@posting.google.com> X-Newsreader: Tom's custom newsreader Message-ID: NNTP-Posting-Host: 12.234.13.56 X-Complaints-To: abuse@attbi.com X-Trace: rwcrnsc53 1032503712 12.234.13.56 (Fri, 20 Sep 2002 06:35:12 GMT) NNTP-Posting-Date: Fri, 20 Sep 2002 06:35:12 GMT Organization: AT&T Broadband Date: Fri, 20 Sep 2002 06:35:12 GMT Xref: archiver1.google.com comp.lang.ada:29203 Date: 2002-09-20T06:35:12+00:00 List-Id: >I'm not elite programmer but I only see a few ways to easily So because you don't know Ada you don't see how to do it simply, and therefore Ada is terrible? That makes a lot of sense. Assuming that, unlike your C++ case, you have no access to any libraries, and trusting you won't hand it in for your homework, I point out: with Ada.Text_IO; procedure Munch is use Ada.Text_IO; package Int_IO is new Integer_IO(Integer); type List_Type is array (Integer range <>) of Integer; Empty_List: List_Type(1 .. 0); function Get return List_Type is Datum : Integer; begin Put("Enter an integer, or 0 to quit:"); Int_IO.Get(Datum); if Datum = 0 then return Empty_List; else return Datum & Get; end if; end Get; List : List_Type := Get; Temp : Integer; begin for I in List'range loop for J in I + 1 .. List'Last loop if List(I) > List(J) then Temp := List(I); List(I) := List(J); List(J) := Temp; end if; end loop; Put_Line(Integer'Image(List(I))); end loop; end Munch;