Write a Ruby program to create an array with the elements "rotated left" of a given array of ints length 3

  • برمجة
  • برمجة روبي

 Write a Ruby program to create an array with the elements "rotated left" of a given array of ints length 3

الأجوبة

def check_array(nums)
    rotated = nums[1], nums[2], nums[0];
	return rotated;
end
print check_array([1, 2, 5]),"\n" 
print check_array([1, 2, 3]),"\n" 
print check_array([1, 2, 4]) 

Output:

[2, 5, 1]
[2, 3, 1]
[2, 4, 1]
هل كان المحتوى مفيد؟

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...