每次生成的随机数都是一样的
r := rand.New(rand.NewSource(time.Now().UnixNano()))
fmt.Println(r.Intn(4))
每次执行结果才不同,才是0~3随机
r := rand.New(rand.NewSource(time.Now().UnixNano()))
fmt.Println(r.Intn(4))
每次执行结果才不同,才是0~3随机
2017-12-09
length := (2)
capacity := (4)
length = (7)
e2 := (0)
e3 := (8)
e4 := (11)
capacity := (4)
length = (7)
e2 := (0)
e3 := (8)
e4 := (11)
2017-11-17
import (
"fmt"
"sync"
)
func main() {
var wg sync.WaitGroup
wg.Add(1)
go func() {
fmt.Println("1")
wg.Done()
}()
wg.Wait()
wg.Add(1)
go func() {
fmt.Println("2")
wg.Done()
}()
wg.Wait()
wg.Add(1)
go func() {
fmt.Println("3")
wg.Done()
}()
wg.Wait()
}
"fmt"
"sync"
)
func main() {
var wg sync.WaitGroup
wg.Add(1)
go func() {
fmt.Println("1")
wg.Done()
}()
wg.Wait()
wg.Add(1)
go func() {
fmt.Println("2")
wg.Done()
}()
wg.Wait()
wg.Add(1)
go func() {
fmt.Println("3")
wg.Done()
}()
wg.Wait()
}
2017-11-04
defer fmt.Printf("%d ", func (n int) int {
v := fibonacci(n)
fmt.Printf("%d ", v)
return v
}(i))
v := fibonacci(n)
fmt.Printf("%d ", v)
return v
}(i))
2017-11-04