Вопрос задан 15.08.2018 в 22:47. Предмет Информатика. Спрашивает Чёрный Иван.

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

[M,M]. (язык программирования delphi).
0 0
Перейти к ответам

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

Внимание! Ответы на вопросы дают живые люди. Они могут содержать ошибочную информацию, заблуждения, а также ответы могут быть сгенерированы нейросетями. Будьте внимательны. Если вы уверены, что ответ неверный, нажмите кнопку "Пожаловаться" под ответом.
Отвечает Шляхтин Марк.
{$APPTYPE CONSOLE}
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.
0 0
Отвечает нейросеть ChatGpt. Будьте внимательны, ответы нейросети могут содержать ошибочные или выдуманные данные.

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.

0 0

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

Последние заданные вопросы в категории Информатика

Задать вопрос