Вопрос задан 18.06.2023 в 11:08. Предмет Информатика. Спрашивает Зятикова Диана.

СОСТАВЬТЕ ПРОГРАММУ ПОИСКА НАИМЕНЬШЕГО ЭЛЕМЕНТА В МАССИВЕ А(10), СОСТОЯЩЕМ ИЗ ЧИСЕЛ :

7,3,4,8,10,-9,6,1,4,-2.
0 0
Перейти к ответам

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

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

Ответ:

Pascsal:  *название массива*.min

Например, writeln(A.min);    A - название массива

Python: min(*название массива*)

Например, print(min(A))       A - название массива

C++:

int A[10] = {7, 3, 4, 8, 10, -9, 6, 1, 4, -2};

int min = A[0];

for(int i = 0; i < 10; i++) {

   if(A[i] < min) { min = A[i]; }

}

0 0
Отвечает Хулпа Маша.

int[] massive = {7,3,4,8,10,-9,6,1,4,-2};

int mn = Integer.MAX_VALUE;

for(int el : massive) {

if(el < mn) {

mn = el;

}

}

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

Program to Find the Smallest Element in an Array

To write a program to find the smallest element in an array A(10) consisting of the numbers: 7, 3, 4, 8, 10, -9, 6, 1, 4, -2, you can use the following algorithm:

1. Initialize a variable `smallest` with the first element of the array. 2. Iterate through the remaining elements of the array. 3. Compare each element with the current value of `smallest`. 4. If the current element is smaller than `smallest`, update the value of `smallest` to the current element. 5. After iterating through all the elements, the value of `smallest` will be the smallest element in the array.

Here's an example of a program written in Python that implements this algorithm:

```python A = [7, 3, 4, 8, 10, -9, 6, 1, 4, -2] smallest = A[0]

for i in range(1, len(A)): if A[i] < smallest: smallest = A[i]

print("The smallest element in the array is:", smallest) ```

When you run this program, it will output:

``` The smallest element in the array is: -9 ```

Please note that this is just one way to solve the problem, and there are other approaches as well. The provided solution iterates through the array and compares each element with the current smallest element. If a smaller element is found, it updates the value of `smallest`.

0 0

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

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

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

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