Professional Documents
Culture Documents
Correction Lab#08
Correction Lab#08
Part I : Algorithms
Exercise No. 01 Exercise No. 03
Algorithm Sum2Mat; Algorithm SEV_COV;
Constants n=10; m=15; Constants n=4; m=8;
Variables Variables
A,B,S: matrix[1..n,1..m] of integer; Mat: matrix[1..n,1..m]of integer;
i, j : integer; i,j,S,Co : integer;
Begin
For i=1 to n Do Begin
For j=1 to m Do For i=1 to n Do
Read (A[i,j]); For j=1 to m Do
EndFor Read (Mat[i,j]);
EndFor EndFor
For i=1 to n Do EndFor
For j=1 to m Do
Read (B[i,j]); For i=1 to n Do
EndFor S0;
EndFor For j=1 to m Do
For i=1 to n Do If (Mat[i,j]mod2 = 0) Then
For j=1 to m Do S S + Mat[i,j];
S[i,j] A[i,j]+B[i,j]; EndIf
EndFor EndFor
EndFor Write('Row:',i,'Sum:',S);
EndFor
For i=1 to n Do
For j=1 to m Do
For j=1 to m Do
Write (S[i,j]);
EndFor Co 0;
EndFor For i=1 to n Do
End. If (Mat[i,j]mod2 <> 0) Then
Co Co + 1;
Exercise No. 02 EndIf
Algorithm MaxIndices; EndFor
Constants n=5; m=5; Write('Column:',j,'Count:',Co);
Variables EndFor
Mat: matrix[1..n,1..m]d’integer; End.
i,j, Max,iMax,jMax: integer;
Begin
For i=1 to n Do
For j=1 to m Do
Read (Mat[i,j]);
EndFor
EndFor
Max Mat[1,1];
iMax 1; jMax 1;
For i=1 to n Do
For j=1 to m Do
If (Mat[i,j]>Max) Then
Max Mat[i,j];
iMax i; jMax j;
EndIf
EndFor
EndFor
Write ('Maximum value =', Max);
Write ('Indices =',iMax, jMax);
End.
UNIVERSITY OF CONSTANTINE 1– CAMPUS CHAAB ERSAS1 ST YEAR COMMON CORE - ST
Computer Science II - Correction of Exercise Series No. 08: Matrices.