- package main
-
- import "fmt"
-
- func max(l []int) (max int) {
- max = l[0]
- for _, v := range l {
- if v > max {
- max = v
- }
- }
- return
- }
-
- func min(l []int) (min int) {
- min = l[0]
- for _, v := range l {
- if v < min {
- min = v
- }
- }
- return
- }
-
- func main() {
- l := []int{1, 3, 4}
- the_max := max(l)
- the_min := min(l)
- fmt.Printf("The max is %d\n", the_max)
- fmt.Printf("The min is %d\n", the_min)
- }
2 条评论
主域名这是不用了吗。
暂时不用了哈!