Skip to content

Commit

Permalink
fprettify styles in example files
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramy-Badr-Ahmed committed Sep 27, 2024
1 parent e4dd573 commit fe82279
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions examples/searches/example_linear_search.f90
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ program linear_search_program

integer, dimension(5) :: array

array = (/ 540, 6, 10, 100, 3 /)
array = (/540, 6, 10, 100, 3/)

!! Search for the number 6 in array.
print*, "Target = 6: ", linear_search(array, 6) !! Prints 2.
print *, "Target = 6: ", linear_search(array, 6) !! Prints 2.

!! Search for the number 5 in array.
print*, "Target = 5: ", linear_search(array, 5) !! Prints -1 because item 5 is not found.
print *, "Target = 5: ", linear_search(array, 5) !! Prints -1 because item 5 is not found.

end program linear_search_program
6 changes: 3 additions & 3 deletions examples/searches/recursive_linear_search.f90
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ program recursive_linear_search_example

integer, dimension(5) :: array

array = (/ 306, 1005, 5, 62, 0 /)
array = (/306, 1005, 5, 62, 0/)

!! Search for the number 62 in the array
print*, "Target = 62: ", recursive_linear_search(array, size(array), 62) !! Prints 4.
print *, "Target = 62: ", recursive_linear_search(array, size(array), 62) !! Prints 4.

!! Search for the number 10 in the array
print*, "Target = 10: ", recursive_linear_search(array, size(array), 10) !! Prints -1 because item 10 is not found.
print *, "Target = 10: ", recursive_linear_search(array, size(array), 10) !! Prints -1 because item 10 is not found.

end program recursive_linear_search_example
2 changes: 1 addition & 1 deletion modules/searches/linear_search.f90
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module linear_search_module

!! This function searches for a target in a given collection.
!! Returns the index of the found target or -1 if target is not found.
function linear_search (collection, target) result(target_index)
function linear_search(collection, target) result(target_index)
integer, dimension(:), intent(in) :: collection !! A collection for elements of type integer
integer, intent(in) :: target !! Target value to be searched.
integer :: target_index !! Target's index in the collection to return.
Expand Down
4 changes: 2 additions & 2 deletions modules/searches/recursive_linear_search.f90
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ recursive function recursive_linear_search(collection, index, target) result(tar
target_index = index
else
!! Recursively search in the remaining part of the collection
target_index = recursive_linear_search(collection, index-1, target)
target_index = recursive_linear_search(collection, index - 1, target)
end if

end function recursive_linear_search

end module recursive_linear_search_module
end module recursive_linear_search_module

0 comments on commit fe82279

Please sign in to comment.