0% found this document useful (0 votes)
14 views2 pages

T06 Matrix

The document discusses matrices and provides 10 exercises to write algorithms for operations on a 20x30 integer matrix including searching for a value, calculating sums and minimums, and counting positive values by column and row.

Uploaded by

An Anes
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views2 pages

T06 Matrix

The document discusses matrices and provides 10 exercises to write algorithms for operations on a 20x30 integer matrix including searching for a value, calculating sums and minimums, and counting positive values by column and row.

Uploaded by

An Anes
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

1st year preparatory class Computer Science

Tutorial N°06: Matrix

A matrix m(x, y) is a two-dimensional data structure (x lines and y columns)


and all of its elements are of the same type.
Example:
to declare mat(10,15) of integers var mat : array[1..10,1..15] of integer;
to declare m(20, 20) of reals var m : array[1..20, 1..20] of real;
we can represent a matrix (for example Mat(5,5)) like this:

COLUMNS 1 2 3 4 5
LINES
Mat[1,1] Mat[1,2] Mat[1,3] Mat[1,4] Mat[1,5]
1
2 Mat[2,1] Mat[2,2] Mat[2,3] Mat[2,4] Mat[2,5]
3 Mat[3,1] Mat[3,2] Mat[3,3] Mat[3,4] Mat[3,5]
4 Mat[4,1] Mat[4,2] Mat[4,3] Mat[4,4] Mat[4,5]
5 Mat[5,1] Mat[5,2] Mat[5,3] Mat[5,4] Mat[5,5]

Initializing Two-Dimensional Arrays:


var
a: array [1..5, 1..10] of integer;
i, j : integer;
begin
for i 1 to 5 do
for j 1 to 10 do
Read(a[i,j]);
endFor
endFor
end.

Exercise 01 :

Given a matrix A(20, 30) of integers, write an algorithm which:


- Search for a given value val in the matrix.

Exercise 02 :

Given a matrix A(20, 30) of integers, write an algorithm which:


- Calculates the sum of the matrix.
Exercise 03 :

Given a matrix A(20, 30) of integers, write an algorithm which:


- Determines the smallest value of the matrix.

Exercise 04 :

Given a matrix A(20, 30) of integers, write an algorithm which:


- Calculates and saves the sum of each column, (you have to use an array
containing the sum of each column).

Exercise 05:

Given a matrix A(20, 30) of integers, write an algorithm which:


- Determines and saves the sum of each line.

Exercise 06 :

Given a matrix A(20, 30) of integers, write an algorithm which:


- Determines and saves the smallest value of each column.

Exercise 07 :

Given a matrix A(20, 30) of integers, write an algorithm which:


- Determines and saves the smallest value of each line.

Exercise 08 :

Given a matrix A(20, 30) of integers, write an algorithm which:


- Counts the number of positive value of the matrix.

Exercise 09 :

Given a matrix A(20, 30) of integers, write an algorithm that:


- Counts the number of positive value of each column.

Exercise 10 :

Given a matrix A(20, 30) of integers, write an algorithm that:


- Counts the number of positive value of each line.

You might also like