Matrice en Pascal

Fermé
caro - 20 mars 2004 à 11:25
 ines - 6 déc. 2010 à 10:39
Bonjour,
Comment faire pour insérer des matrices dans Turbo Pascal, j'suis en pleine galere, aidez moi...
(J'avais penser a un tableau a 2 dimensions mais je ne vois pas comment m'y prendre)

Merci bcp d'avance
A voir également:

2 réponses

Marmot Messages postés 579 Date d'inscription lundi 14 janvier 2002 Statut Membre Dernière intervention 17 août 2006 69
20 mars 2004 à 11:30
Ben si

Exemple de calcul de produit matriciel (et d'autres sur le web)

program produit_mat(input,output);
var m1,m2,m3:array[1..10,1..10]of real;
l,m,n,jl,jm,jn:integer;
begin
writeln('nb lignes 1ère matrice ?');
readln(m);
writeln('nb colonnes 1è matrice ?');
readln(l);
writeln('nb colonnes 2è matrice ?');
readln(n);
(* entrée de m1 *)
writeln('première matrice');
for jm:=1 to m do for jl:=1 to l do
begin
writeln('lig',jm,', col',jl,'?');
readln(m1[jm,jl])
end;
(* entrée de m2 *)
writeln('2ième matrice');
for jl:=1 to l do for jn:=1 to n do
begin
writeln('lig',jl,', col',jn,'?');
readln(m2[jl,jn])
end;
(* calcul du produit *)
for jm:=1 to m do for jn:=1 to n do
begin {calcul composante m,n de m2}
m3[jm,jn]:=0;
for jl:=1 to l do m3[jm,jn]:=
m3[jm,jn]+(m1[jm,jl]*m2[jl,jn]);
end;
(* affichage du résultat *)
writeln('résultat');
for jm:=1 to m do for jn:=1 to n do
writeln('m[',jm,',',jn,']=',
m3[jm,jn])
end.
12
uses wincrt? pour traduit les opération d'entré et les opération de sortie(readln,writeln)
0