You are given an NxN matrix consisting of zeros and ones. You need to count the number of units in it.

program zz1;

const n = 4; // set the number of elements in the array

var i, j, k: integer; // set variables of integer type

a: array [1..n, 1..n] of integer;

begin

for i: = 1 to n do

for j: = 1 to n do // get numbers and write them into an array

a [i, j]: = random (2);

for i: = 1 to n do // display the resulting array on the screen

begin

for j: = 1 to n do

write (a [i, j]: 4);

writeln;

end;

for i: = 1 to n do

for j: = 1 to n do

if a [i, j] = 1 then k: = k + 1; // check if the element is equal to one, then count it

writeln (‘the number of array elements equal to one =’, k); // display the answer

end.



One of the components of a person's success in our time is receiving modern high-quality education, mastering the knowledge, skills and abilities necessary for life in society. A person today needs to study almost all his life, mastering everything new and new, acquiring the necessary professional qualities.