Created
November 3, 2018 21:26
-
-
Save Crilou/c107cfed020cde85d82ce0d7d2cca007 to your computer and use it in GitHub Desktop.
Go=>Array+Slices
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func whereismymin(Slice []float64) int { | |
var N int = len(Slice) | |
var min float64 = Slice[0] | |
var posmin int | |
for i:=1 ; i<N ; i++ { | |
if Slice[i]<min { | |
min = Slice[i] | |
posmin = i | |
} | |
} | |
return posmin | |
} | |
func whereismymax(Slice []float64) int { | |
var N int = len(Slice) | |
var max float64 = Slice[0] | |
var posmax int | |
for i:=1 ; i<N ; i++ { | |
if Slice[i]>max { | |
max = Slice[i] | |
posmax = i | |
} | |
} | |
return posmax | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment