Вопрос задан 19.02.2019 в 05:56. Предмет Информатика. Спрашивает Вавилов Захар.

Все 4 задания,бужу очень благодарен 1)заполнить одномерный массив 10-ю случайными числами из

диапазона от 30 до 40 2) вывести массив на печать в строку. 3)найти и вывести сумму минимального и максимального элементов массива. 4)вывести на печать в строку элементы массива,меньшие 35
0 0
Перейти к ответам

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

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

Task 1: Fill a one-dimensional array with 10 random numbers from 30 to 40

To fill a one-dimensional array with 10 random numbers from 30 to 40, you can use the following Bash script:

```bash #!/bin/bash

# Declare an array declare -a arr

# Fill the array with 10 random numbers from 30 to 40 for ((i=0; i<10; i++)); do arr[i]=$((RANDOM % 11 + 30)) done ```

Task 2: Print the array in a single line

To print the array in a single line, you can use the following Bash script:

```bash # Print the array in a single line echo "${arr[@]}" ``` This will output the array in a single line.

Task 3: Find and print the sum of the minimum and maximum elements of the array

To find and print the sum of the minimum and maximum elements of the array, you can use the following Bash script:

```bash # Find the minimum and maximum elements of the array min=${arr[0]} max=${arr[0]} for num in "${arr[@]}"; do ((num < min)) && min=$num ((num > max)) && max=$num done

# Print the sum of the minimum and maximum elements echo "Sum of min and max: $(($min + $max))" ``` This will calculate and print the sum of the minimum and maximum elements of the array.

Task 4: Print the elements of the array that are less than 35 in a single line

To print the elements of the array that are less than 35 in a single line, you can use the following Bash script:

```bash # Print the elements of the array that are less than 35 for num in "${arr[@]}"; do ((num < 35)) && echo -n "$num " done ``` This will output the elements of the array that are less than 35 in a single line.

0 0

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

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

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