Sintaxa de declarare a unei matrice este: tip nume[m][n], unde:
* tip – tipul de data folosit; poate fi unul din tipurile de baza (int, char, …) sau un tip definit de utilizator (articole, obiecte)
* nume – numele prin care va fi referita matricea
* m – numarul de linii din matrice
* n- numarul de coloane din matrice
Blocul de introducere:
For i:=1 to n do
For j:=1 to m do begin
write('A[,'i,j',]=');
readln(A[i,j];
end;
Blocul de afisare:
For i:=1 to n do begin
For j:=1 to m do
write(A[i,j]:4);
writeln;
end;
Program P7;
var A:array [1..100,1..100] of integer;
var i,j,n,m,s:integer;
begin
writeln ('Introduceti n'); readln (n);
writeln ('íntroduceti m'); readln (m);
For i:=1 to n do
For j:=1 to m do begin
write('A[,'i,j',]=');
readln(A[i,j];
end;
For i:=1 to n do begin
For j:=1 to m do
write(A[i,j]:4);
writeln;
end;
Program P7;
var A:array [1..100,1..100] of integer;
var i,j,n,m,s:integer;
begin
writeln ('Introduceti n'); readln (n);
writeln ('íntroduceti m'); readln (m);
For i:=1 to n do
For j:=1 to m do begin
write('A[,'i,j',]=');
readln(A[i,j];
end;
For i:=1 to n do begin
For j:=1 to m do
write(A[i,j]:4);
writeln;
end;
Niciun comentariu:
Trimiteți un comentariu