-------------------------------------------------------------------------------- -- * Prog name exo01.adb -- * Project name td_01_03 -- * -- * Version 1.0 -- * Last update 11/09/08 -- * -- * Created by Pierre-Franois LŽon on 11/09/08. -- * Copyright (c) 2008 __MyCompanyName__. -- * All rights reserved. -- * or (keep only one line or write your own) -- * GNAT modified GNU General Public License -- * -------------------------------------------------------------------------------- with Ada.Text_IO, ada.integer_text_io; with Ada.Numerics.Discrete_Random; use Ada.Text_IO, ada.integer_text_io; procedure Exo01 is N : constant Positive := 5; M : constant Positive := 4; type Matrix is array (1..N, 1..M) of Float; -- comparaisons : N*M*4 function IsYoungMatrix_m1(M : in Matrix) return Boolean is begin for I in M'Range(1) loop for J in M'Range(2) loop if I < M'Last(1) then if M(I, J) > M(I + 1, J) then return False; end if; end if; if J < M'Last(2) then if M(I, J) > M(I, J + 1) then return False; end if; end if; end loop; end loop; return True; end IsYoungMatrix_m1; -- comparaisons : (n - 1) * (m - 1) * 2 + m + n - 2 -- = 2 * n * m - 2n - 2m + 2 + m + n - 2 -- = 2 * n * m - n - m function IsYoungMatrix_m2(M : in Matrix) return Boolean is begin for I in M'First(1)..M'Last(1) - 1 loop for J in M'First(2)..M'Last(2) - 1 loop if M(I, J) > M(I + 1, J) or M(I, J) > M(I, J + 1) then return False; end if; end loop; end loop; for I in M'First(1)..M'Last(1) - 1 loop if M(I, M'Last(2)) > M(I + 1, M'Last(2)) then return False; end if; end loop; for J in M'First(2)..M'Last(2) - 1 loop if M(M'Last(1), J) > M(M'Last(1), J + 1) then return False; end if; end loop; return True; end IsYoungMatrix_m2; begin null; end Exo01;