mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-08-12 05:11:49 +08:00
Update 07.3.md and 07.6.md (#273)
* Update 07.3.md * Update 07.3.md * Update 07.6.md
This commit is contained in:
@@ -7,7 +7,7 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
sl1 := []int{78,34,643,12,90,492, 13, 2}
|
||||
sl1 := []int{78, 34, 643, 12, 90, 492, 13, 2}
|
||||
max := maxSlice(sl1)
|
||||
fmt.Printf("The maximum is %d\n", max)
|
||||
min := minSlice(sl1)
|
||||
@@ -20,20 +20,21 @@ func maxSlice(sl []int) (max int) {
|
||||
max = v
|
||||
}
|
||||
}
|
||||
return
|
||||
return
|
||||
}
|
||||
|
||||
func minSlice(sl [] int) (min int) {
|
||||
// min = int(^uint(0) >> 1)
|
||||
min = math.MaxInt32
|
||||
func minSlice(sl []int) (min int) {
|
||||
// min = int(^uint(0) >> 1)
|
||||
min = math.MaxInt32
|
||||
for _, v := range sl {
|
||||
if v < min {
|
||||
min = v
|
||||
}
|
||||
}
|
||||
return
|
||||
return
|
||||
}
|
||||
|
||||
/* Output:
|
||||
The maximum is 643
|
||||
The minimum is 2
|
||||
*/
|
||||
*/
|
||||
|
Reference in New Issue
Block a user