ruby BE101会议1家庭作业答案
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ruby BE101会议1家庭作业答案相关的知识,希望对你有一定的参考价值。
def max(numbers)
numbers.sort.last
end
puts max([50, -9, 77, 91, 34])
def fizzbuzz(num)
return "fizzbuzz" if (num % 3 == 0) && (num % 5 == 0)
return "fizz" if num % 3 == 0
return "buzz" if num % 5 == 0
num
end
(1..100).to_a.each {|n| puts fizzbuzz(n) }
def combine(array_one, array_two)
combination = {}
array_one.each_with_index do |key, index|
combination[key] = array_two[index]
end
combination
end
puts combine([:a, :b, :c], [1, 2, 3])
def america_phrase(phrase)
"#{phrase}; Only in America!"
end
puts "Enter a phrase"
input = gets.chomp
puts america_phrase(input)
以上是关于ruby BE101会议1家庭作业答案的主要内容,如果未能解决你的问题,请参考以下文章