comp.lang.ada
 help / color / mirror / Atom feed
From: ashraf2000@x-stream.co.uk
Subject: HELP WITH SIMPLE PROGRAM PLEASE
Date: 2000/04/17
Date: 2000-04-17T00:00:00+00:00	[thread overview]
Message-ID: <8df1sn$hh4$1@nnrp1.deja.com> (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.




             reply	other threads:[~2000-04-17  0:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-04-17  0:00 ashraf2000 [this message]
2000-04-17  0:00 ` HELP WITH SIMPLE PROGRAM PLEASE Robert Dewar
2000-04-17  0:00 ` Ted Dennison
2000-04-18  0:00 ` Sort, was " Alfred Hilscher
replies disabled

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