Last active
October 17, 2019 09:49
-
-
Save Jason-cqtan/59b32931b84cbe23f44b5f96c9affbd2 to your computer and use it in GitHub Desktop.
生成随机数
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
package main | |
import ( | |
"fmt" | |
"math/rand" | |
"time" | |
) | |
func main() { | |
for i := 0; i < 10; i++ { | |
a := rand.Int() | |
fmt.Printf("%d / ", a) | |
} | |
fmt.Println() | |
for i := 0; i < 5; i++ { | |
r := rand.Intn(8) | |
fmt.Printf("%d / ", r) | |
} | |
fmt.Println() | |
timens := int64(time.Now().Nanosecond()) | |
fmt.Println(timens) | |
rand.Seed(timens) | |
for i := 0; i < 10; i++ { | |
fmt.Printf("%2.2f / ", 100*rand.Float32()) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment