This file contains hidden or 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
# 3) Дан целочисленный массив. Заменить все положительные элементы на значение минимального. | |
class Max2MinArrayElement | |
# Условие описано не ясно. Минимальных елементов здесь 2: | |
# Минимальное отрицательное | |
# Минимальное положительное | |
def initialize | |
@the_greatest_array = Array.new(15){rand(-100...100)} | |
end | |
# Решение первое. При минимальном отрицательном | |
def negative_change |
This file contains hidden or 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
# 2) В одном массиве записан рост некоторых студентов, а в другом | |
# (с тем же числом элементов) - их фамилии в том же порядке, в котором указан рост. | |
# Известно, что все студенты разного роста. Напечатайте фамилию самого высокого студента. | |
def perform | |
growth = Array.new(6){rand(150..200)} | |
surname = ["Anderson", "Ashwoon", "Aikin", "Bateman", "Bongard", "Bowers"] | |
group = surname.zip(growth) | |
group_h = Hash[group] |
This file contains hidden or 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
# 1) В одном массиве записано количество мячей, забитых футбольной командой в каждой из 20 игр, | |
# в другом - количество пропущенных мячей в этой же игре. Для каждой игры определите | |
# словесный результат игры (выигрыш, проигрыш или ничью). (edited) | |
class GameStatisticAttraction | |
def perform | |
goal = Array.new(20){rand(1...10)} | |
miss = Array.new(20){rand(1...10)} | |
game = Hash[goal.zip(miss)] |
NewerOlder