Created
March 28, 2012 22:06
-
-
Save koistya/2230969 to your computer and use it in GitHub Desktop.
Pick some random numbers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Дано: Цикл, который перебирает все элементы массива данных. Размер массива может быть любым. | |
// В цикле можно совершать любые действия, но нельзя запускать этот цикл повторно. | |
// Найти: Сумму только пяти случайных элементов, которые можно получить этим циклом: | |
var i = 0, sum = 0; | |
while (i < sizeof(array)) | |
{ | |
sum += array[i]; | |
i++; | |
} | |
// alert('Сумма: ' + sum); | |
// Выводит сумму всех элементов массива, а нам нужна сумма только пяти случайных элементов. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment