Yurttas/PL/IL/Ada-95/F/01/PU/minni p.adb

 1--
 2
 3-- date   : January 1, 1998.
 4-- authorĀ : Salih Yurttas.
 5
 6-- package body
 7--
 8-- minni_p.adb
 9
10package body Minimum_of_N_Integers_P is
11
12  package Int_IO is new Integer_IO(Integer);
13  use Int_IO;
14
15  procedure Get_Integer_List(K : out Integer;
16                             D : out Integer_List) is
17
18    In_File_P : File_Type;
19
20    I : Integer := 0;
21
22  begin
23
24    Open(In_File_P, In_File, "in.txt");
25
26    while not End_of_File(In_File_P)
27    loop
28      I := I + 1;
29      Get(In_File_P, D(I));
30    end loop;
31    K := I;
32
33    Close(In_File_P);
34
35  end Get_Integer_List;
36
37  procedure Find_Min_of_Integer_List(Min,
38                                     J    : out Integer;
39                                     K    : in Integer;
40                                     D    : in ListI) is
41    M : Integer;
42
43  begin
44
45    M := D(1);
46    J := 1;
47    for I in 2..K
48    loop
49      if D(I)then
50        M := D(I);
51        J := I;
52      end if;
53    end loop;
54    Min := M;
55
56  end Find_Minimum_of_Integer_List;
57
58  procedure Put_Minimum_of_Integer_List(Min,
59                                        J    : in Integer) is
60    Out_File_P : File_Type;
61
62  begin
63
64    Create(Out_File_P, Out_File, "out.txt");
65
66    Put(Out_File_P,"D(");
67    Put(Out_File_P,J,1);
68    Put(Out_File_P,") = ");
69    Put(Out_File_P,Min,5);
70    Put(Out_File_P," is the minimum of the list.");
71
72    Close(Out_File_P);
73
74  end Put_Minimum_of_Integer_List;
75
76end Minimum_of_N_Integers_P;