Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
32
Task/Binary-search/HicEst/binary-search-1.hicest
Normal file
32
Task/Binary-search/HicEst/binary-search-1.hicest
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
REAL :: n=10, array(n)
|
||||
|
||||
array = NINT( RAN(n) )
|
||||
SORT(Vector=array, Sorted=array)
|
||||
x = NINT( RAN(n) )
|
||||
|
||||
idx = binarySearch( array, x )
|
||||
WRITE(ClipBoard) x, "has position ", idx, "in ", array
|
||||
END
|
||||
|
||||
FUNCTION binarySearch(A, value)
|
||||
REAL :: A(1), value
|
||||
|
||||
low = 1
|
||||
high = LEN(A)
|
||||
DO i = 1, high
|
||||
IF( low > high) THEN
|
||||
binarySearch = 0
|
||||
RETURN
|
||||
ELSE
|
||||
mid = INT( (low + high) / 2 )
|
||||
IF( A(mid) > value) THEN
|
||||
high = mid - 1
|
||||
ELSEIF( A(mid) < value ) THEN
|
||||
low = mid + 1
|
||||
ELSE
|
||||
binarySearch = mid
|
||||
RETURN
|
||||
ENDIF
|
||||
ENDIF
|
||||
ENDDO
|
||||
END
|
||||
2
Task/Binary-search/HicEst/binary-search-2.hicest
Normal file
2
Task/Binary-search/HicEst/binary-search-2.hicest
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
7 has position 9 in 0 0 1 2 3 3 4 6 7 8
|
||||
5 has position 0 in 0 0 1 2 3 3 4 6 7 8
|
||||
Loading…
Add table
Add a link
Reference in a new issue