Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def sequential_search(arr, target):
- for i in range(len(arr)):
- if arr[i] == target:
- return i
- return -1
- array = ["apple", "banana", "cherry", "date", "elderberry"]
- target = "cherry"
- result = sequential_search(array, target)
- if result != -1:
- print(f"Элемент {target} найден в массиве на позиции {result}.")
- else:
- print(f"Элемент {target} не найден в массиве.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement