
ЭЛЕМЕНТЫ МАССИВА, ИНФОРМАТИКА, 9 КЛАСС. Заполнить массив кубами 10 натуральных чисел и посчитать
сумму первых 7 элементов массива. Помогите, пожалуйста, срочно нужно.

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

// Внимание! Если программа не работает, обновите версию!
begin
var a:=ArrGen(10,i->(i+1)*sqr(i+1)); a.Println;
Writeln('S7=',a.Take(7).Sum);
end.
Результат
1 8 27 64 125 216 343 512 729 1000
S7=784






Array Elements and Sum Calculation
To fill an array with cubes of 10 natural numbers and calculate the sum of the first 7 elements, you can use the following Java code:
```java public class ArraySum { public static void main(String[] args) { int[] array = new int[10]; int sum = 0;
for (int i = 0; i < 10; i++) { array[i] = (i + 1) * (i + 1) * (i + 1); if (i < 7) { sum += array[i]; } }
System.out.println("The array filled with cubes of 10 natural numbers: " + Arrays.toString(array)); System.out.println("The sum of the first 7 elements of the array: " + sum); } } ```
In this code, we initialize an array of size 10 and fill it with the cubes of the first 10 natural numbers. Then, we calculate the sum of the first 7 elements of the array.
This code will output the filled array and the sum of the first 7 elements when executed.
Let me know if you need further assistance!


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








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