home *** CD-ROM | disk | FTP | other *** search
/ Chip 1995 March / CHIP3.mdf / programm / prog2 / answers / ch10_2.ada < prev    next >
Encoding:
Text File  |  1991-07-01  |  981 b   |  48 lines

  1.                           -- Chapter 10 - Programming exercise 2
  2. with Text_IO;
  3. use Text_IO;
  4.  
  5. procedure Ch10_2 is
  6.  
  7. package INt_IO is new Text_IO.Integer_IO(INTEGER);
  8. use Int_IO;
  9.  
  10. type MATRIX is array(1..3,1..5) of INTEGER;
  11.  
  12. First  : MATRIX := ((1, 1, 1, 1, 1),
  13.                     (2, 2, 2, 2, 2),
  14.                     (3, 3, 3, 3, 3));
  15.  
  16. Second : MATRIX := ((1, 2, 3, 4, 5),
  17.                     (1, 2, 3, 4, 5),
  18.                     (1, 2, 3, 4, 5));
  19.  
  20. Result : MATRIX;
  21.  
  22. begin
  23.    for Index1 in 1..3 loop
  24.       for Index2 in 1..5 loop
  25.          Result(Index1, Index2) := First(Index1, Index2) *
  26.                                    Second(Index1, Index2);
  27.       end loop;
  28.    end loop;
  29.  
  30.    for Index1 in 1..3 loop
  31.       for Index2 in 1..5 loop
  32.          Put(Result(Index1, Index2),4);
  33.       end loop;
  34.       New_Line;
  35.    end loop;
  36. end Ch10_2;
  37.  
  38.  
  39.  
  40.  
  41. -- Result of execution
  42.  
  43. --    1   2   3   4   5
  44. --    2   4   6   8  10
  45. --    3   6   9  12  15
  46.  
  47.  
  48.