Вопрос про Random | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Вопрос про Random

Подскажите пожалуйста, как сгенерировать 2 случайных целых числа от 1 до 10, что бы в консоль выводились разные примеры из этих чисел, ну например (3 * 6; 5*2 и т.д), что бы не повторялись?))

28th Aug 2022, 4:01 PM
Юлия Тарасова
1 Answer
0
Use a List. Fill the list with the numbers 1 to 10. Use Random to randomly select an index from the list, depending on the current size of the List. Use the number found at that index in List, then remove the number from the List. Repeat in a loop until the List is empty or other condition is satisfied.
29th Aug 2022, 9:20 AM
Brian
Brian - avatar