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

  1.                                        -- Chapter 10 - Program 2
  2. with Text_IO;
  3. use Text_IO;
  4.  
  5. procedure Slice 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..12) of INTEGER;
  11.  
  12.    First, Second  : MY_ARRAY;
  13.    Funny          : array(1..33) of INTEGER;
  14.  
  15. begin
  16.  
  17.    for Index in 1..33 loop
  18.       Funny(Index) := 100 + Index * 2;
  19.    end loop;
  20.  
  21.    for Index in 1..12 loop
  22.       First(Index) := Index;
  23.    end loop;
  24.  
  25.    Second(1..5) := First(3..7);
  26.    Second(1..4) := First(6..9);
  27.    Second(7..12) := First(3..8);
  28.    First(2..9) := First(5..12);
  29.  
  30.    First(1..12) := MY_ARRAY(Funny(1..12));
  31.    First(1..12) := MY_ARRAY(Funny(16..27));
  32.  
  33.    for Index in 1..12 loop
  34.       Put("The array named First has the values ");
  35.       Put(First(Index));
  36.       New_Line;
  37.    end loop;
  38. end Slice;
  39.  
  40.  
  41.  
  42.  
  43. -- Result of execution
  44.  
  45. -- The array named First has the values    132
  46. -- The array named First has the values    134
  47. -- The array named First has the values    136
  48. -- The array named First has the values    138
  49. -- The array named First has the values    140
  50. -- The array named First has the values    142
  51. -- The array named First has the values    144
  52. -- The array named First has the values    146
  53. -- The array named First has the values    148
  54. -- The array named First has the values    150
  55. -- The array named First has the values    152
  56. -- The array named First has the values    154
  57.  
  58.