1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
Program test;
uses crt;
var
I,J,N:integer ;
mat: array of array of Integer;
triangleSup,triangleInf :boolean;
Begin
clrscr;
writeln('Encodage de la matrice');
Write('orde de la matrice carree : ');
readln(N);
setLength(mat,N,N);{fixe les dimensions du tableau dynamique}
{--------------- Encodage -----------------------------}
for I:=0 to N-1 do
begin
writeln('ligne ',I:2);
for J:=0 to N-1 do
begin
write(' cellule [',i,',',j,'] :');
readln(mat[I,J]);
end;
end;
writeln('******* Affichage de la Matrice *********************');
for I:=0 to N-1 do
begin
for J:=0 to N-1 do
begin
write(mat[I,J]:6,' |');
end;
writeln;
end;
writeln('---------------------------');
triangleSup := true;
triangleInf := true;
I:=1;J:=0;
while triangleSup and( I<N) do
begin
while triangleSup and( J<I) do
begin
if mat[I,J]<>0 then triangleSup:=false;
inc(J);
end;
J:=0;
inc(I);
end;
if triangleSup then writeln('Matrice triangulaire superieure');
I:=0;J:=1;
while triangleInf and (I<N) do
begin
while triangleInf and (J<N) do
begin
if mat[I,J]<>0 then triangleInf:=false;
inc(J);
end;
inc(I);
J:=I+1;
end;
if triangleInf then writeln('Matrice triangulaire inferieure');
End. |
Partager