Write a Ruby program to check two given arrays of integers and test whether they have the same first element
- برمجة
- برمجة روبي
- 2021-08-31
- mhanasmh00489829403
الأجوبة
def check_array(a, b)
return (a[0] == b[0] || a[a.length-1] == b[b.length-1])
end
print check_array([1, 2, 5], [7, 5]),"\n"
print check_array([1, 2, 3], [7, 3, 2]),"\n"
print check_array([1, 2, 4], [1, 4])
Output:
true false true
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال