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