comp.lang.ada
 help / color / mirror / Atom feed
* HELP WITH SIMPLE PROGRAM PLEASE
@ 2000-04-17  0:00 ashraf2000
  2000-04-17  0:00 ` Robert Dewar
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: ashraf2000 @ 2000-04-17  0:00 UTC (permalink / raw)


HI,

I am a beginner and trying to sort numbers which are read from a file
in random order and needs to be sorted out in numerical order.
e.g 7,10,1,5,.... into 1,2,3,....
Below is some code to read the number from a file and display them.

Please help me sort them out.

THANKS in advance.
ashraf2000@x-stream.co.uk

----------------------------------
NOTE: i'm using ADAGIDE.
The program doesn't takes input from user. Uses a text file to read
data. (run-runoptions-redirectinput ... to be specific)
----------------------------------
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
with Ada.Float_Text_IO; use Ada.Float_Text_IO;
with Ada.Numerics.Elementary_Functions;
use Ada.Numerics.Elementary_Functions;

procedure digits_sort is

type no_type is array (1..10) of integer;
no:no_type;

   procedure read is
   begin
      for x in no'first..no'last loop
         get(no(x));
         new_line;
         put(no(x),2);
      end loop;
   end read;

   procedure check is
   temp:integer;
   begin
      if no(1)>no(2) then
         temp:=no(1);
         no(1):=no(2);
         no(2):=temp;
      end if;
   end check;

   procedure output is
   begin
   new_line(3);
      for i in 1..10 loop
         put(no(i),2);
         new_line;
      end loop;
   end output;

begin
read;
check;
output;
end digits_sort;


Sent via Deja.com http://www.deja.com/
Before you buy.




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2000-04-18  0:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-04-17  0:00 HELP WITH SIMPLE PROGRAM PLEASE ashraf2000
2000-04-17  0:00 ` Robert Dewar
2000-04-17  0:00 ` Ted Dennison
2000-04-18  0:00 ` Sort, was " Alfred Hilscher

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox