
Подпрограмма процедура. Найти количество положительных элементов чётных столбцов матриц A[N,N] и B
[M,M]. (язык программирования delphi).

Ответы на вопрос

Type
Mass = array of array of integer;
Procedure KP(Var A:Mass; N:integer);
Var i,j,k:integer;
Begin
k:=0;
For j:= 0 to N-1 do
if j mod 2 = 0 then
For i:= 0 to N-1 do
if A[i,j] > 0 then k:=k+1;
WriteLn('k = ',k)
End;
Procedure RND(Var A:Mass; N:integer);
Var i,j:integer;
Begin
Randomize;
SetLength(A,N,N);
For i:= 0 to N-1 do
Begin
For j:= 0 to N-1 do
Begin
A[i,j]:=random(21)-10;
Write(A[i,j]:3,' ')
End;
WriteLn
End;
End;
Var
A,B:Mass;
N,M:integer;
Begin
Write('N = ');ReadLn(N);
WriteLn('A(',N,',',N,'):');
RND(A,N);
KP(A,N);
Write('M = ');ReadLn(M);
WriteLn('B(',M,',',M,'):');
RND(B,M);
KP(B,M);
ReadLn
End.



Subprogram Procedure to Find the Number of Positive Elements in Even Columns of Matrices A[N,N] and B[M,M] (Delphi)
To achieve this, you can create a subprogram procedure in Delphi to find the number of positive elements in even columns of matrices A[N,N] and B[M,M]. Here's a detailed explanation of how you can accomplish this:
1. Define the Matrices A[N,N] and B[M,M]: - First, define the matrices A[N,N] and B[M,M] in your Delphi program. These matrices will hold the elements for which you want to find the count of positive elements in even columns.
2. Create a Subprogram Procedure: - Next, create a subprogram procedure specifically designed to find the number of positive elements in even columns of the matrices A[N,N] and B[M,M].
3. Iterate Through Even Columns: - Within the subprogram procedure, iterate through the even columns of the matrices A[N,N] and B[M,M]. For each even column, count the number of positive elements.
4. Count Positive Elements: - For each even column, count the number of positive elements present. Keep track of this count for each even column.
5. Return the Total Count: - Finally, return the total count of positive elements in the even columns of the matrices A[N,N] and B[M,M] from the subprogram procedure.
Here's a Delphi-like pseudocode to illustrate the subprogram procedure:
```delphi procedure CountPositiveElementsInEvenColumns(A: array[N,N] of Integer; B: array[M,M] of Integer; N, M: Integer); var count: Integer; i, j: Integer; begin count := 0; for j := 2 to N do // Iterate through even columns of matrix A begin for i := 1 to N do // Iterate through rows of matrix A begin if (A[i, j] > 0) then // Check if the element is positive count := count + 1; // Increment the count of positive elements end; end;
for j := 2 to M do // Iterate through even columns of matrix B begin for i := 1 to M do // Iterate through rows of matrix B begin if (B[i, j] > 0) then // Check if the element is positive count := count + 1; // Increment the count of positive elements end; end;
// Return the total count of positive elements in even columns of matrices A[N,N] and B[M,M] ShowMessage('Total count of positive elements in even columns: ' + IntToStr(count)); end; ```
You can integrate this subprogram procedure into your Delphi program to achieve the desired functionality.


Топ вопросов за вчера в категории Информатика








Последние заданные вопросы в категории Информатика
-
Математика
-
Литература
-
Алгебра
-
Русский язык
-
Геометрия
-
Английский язык
-
Химия
-
Физика
-
Биология
-
Другие предметы
-
История
-
Обществознание
-
Окружающий мир
-
География
-
Українська мова
-
Информатика
-
Українська література
-
Қазақ тiлi
-
Экономика
-
Музыка
-
Право
-
Беларуская мова
-
Французский язык
-
Немецкий язык
-
МХК
-
ОБЖ
-
Психология
-
Физкультура и спорт
-
Астрономия
-
Кыргыз тили
-
Оʻzbek tili