home *** CD-ROM | disk | FTP | other *** search
/ Chip 1995 March / CHIP3.mdf / programm / prog2 / arryinit.ada < prev    next >
Encoding:
Text File  |  1991-07-01  |  1.4 KB  |  55 lines

  1.                                        -- Chapter 10 - Program 6
  2. with Text_IO;
  3. use Text_IO;
  4.  
  5. procedure ArryInit is
  6.  
  7.    package Int_IO is new Text_IO.Integer_IO(INTEGER);
  8.    use Int_IO;
  9.  
  10.    type MY_ARRAY is array(1..5) of INTEGER;
  11.  
  12.    Total : MY_ARRAY := (12, 27, -13, 122, 44);
  13.    First : MY_ARRAY := (1 => 14, 2 => 57, 3=> 111,
  14.                                  5 => -27, 4 => 21);
  15.  
  16.    Another : MY_ARRAY := (2 => 13, 5 => 57, others => 3);
  17.  
  18.    One_More : MY_ARRAY := (2..4 => 13, 1 | 5 => 27);
  19.  
  20.    type MATRIX is array(INTEGER range 1..3,
  21.                         INTEGER range 1..4) of INTEGER;
  22.  
  23.    Square_Board : MATRIX := ((4, 7, 3, 5),
  24.                              (3, 8, 2, 0),
  25.                              (1, 5, 9, 9));
  26.  
  27.    Checker_Board : MATRIX := (2 => (3, 8, 2, 0),
  28.                               3 => (1, 5, 9, 9),
  29.                               1 => (4, 7, 3, 5));
  30.  
  31.    Chess_Board : MATRIX := (2 => (3, 8, 2, 0),
  32.                             3 => (1, 5, 9, 9),
  33.                             1 => (4 => 5, 2 => 7, 1 => 4, 3 => 3));
  34.  
  35. begin
  36.  
  37.    if Square_Board = Checker_Board then
  38.       Put_Line("The two arrays are equal.");
  39.    end if;
  40.  
  41.    if Chess_Board = Square_Board then
  42.       Put_Line(" and so are the other two.");
  43.    end if;
  44.  
  45. end ArryInit;
  46.  
  47.  
  48.  
  49.  
  50. -- Result of execution
  51.  
  52. -- The two arrays are equal.
  53. --  and so are the other two.
  54.  
  55.