Вопрос задан 08.12.2023 в 06:15. Предмет Информатика. Спрашивает Федів Антон.

Даний двовимірний масив дійсних чисел розміром 10х10. Написати програму, яка обчислює, скільки

разів введене з клавіатури число зустрічається в масиві. Програму реалізувати на мові Паскаль з використанням підпрограм..
0 0
Перейти к ответам

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

Внимание! Ответы на вопросы дают живые люди. Они могут содержать ошибочную информацию, заблуждения, а также ответы могут быть сгенерированы нейросетями. Будьте внимательны. Если вы уверены, что ответ неверный, нажмите кнопку "Пожаловаться" под ответом.
Отвечает Хан Нұрдос.

Ответ:

  • begin
  • var m := ReadMatrReal(10,10);
  • var n := ReadReal('n:');
  • m.ElementsByRow.Count(x->x=n).Print
  • end.

Пример работы (с матрицей 3х3):


0 0
Отвечает нейросеть ChatGpt. Будьте внимательны, ответы нейросети могут содержать ошибочные или выдуманные данные.

To solve this problem, you can write a program in Pascal that prompts the user to enter a number and then counts how many times that number appears in a 10x10 two-dimensional array of real numbers. Here's an example implementation:

```pascal program CountOccurrences;

const SIZE = 10;

type RealArray = array[1..SIZE, 1..SIZE] of real;

var arr: RealArray; number: real;

procedure InitializeArray(var arr: RealArray); var i, j: integer; begin for i := 1 to SIZE do for j := 1 to SIZE do arr[i, j] := random(100); // You can modify this to initialize the array with your own values end;

function CountOccurrencesInArray(arr: RealArray; number: real): integer; var i, j, count: integer; begin count := 0; for i := 1 to SIZE do for j := 1 to SIZE do if arr[i, j] = number then count := count + 1; CountOccurrencesInArray := count; end;

begin InitializeArray(arr); writeln('Enter a number:'); readln(number); writeln('The number ', number:0:2, ' appears ', CountOccurrencesInArray(arr, number), ' times in the array.'); end. ```

In this program, the `InitializeArray` procedure is used to initialize the 10x10 array with random real numbers. You can modify this procedure to initialize the array with your own values if needed.

The `CountOccurrencesInArray` function takes the array and the number entered by the user as parameters and counts how many times the number appears in the array. It uses nested loops to iterate over each element of the array and compares it with the input number.

Finally, the program prompts the user to enter a number, calls the `CountOccurrencesInArray` function to count the occurrences of that number in the array, and displays the result.

Please note that this is just one possible implementation of the program. There are many ways to solve this problem, and you can modify the code according to your specific requirements.

0 0

Похожие вопросы

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

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

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