Es gab eine Anfrage aus der Liste der Listen, ** x Personen ** zu machen, also schrieb ich sie in go-Sprache.
package main
import (
"fmt"
"math/rand"
"time"
)
func main() {
list := [...]string{"mano", "hiori", "meguru",
"kogane", "mmm", "mitsumine", "sakuya", "kiriko",
"kaho", "choko", "jyuri", "rinze", "natsuha",
"amana", "tenka", "chiyuki",
"asahi", "huyu", "mei",
"toru", "higuchi", "pya", "hinana"}
//Wie man teilt
parse := 5
//Slice mit der angezeigten Zufallszahl
var slice []int
rand.Seed(time.Now().UnixNano())
for i := 1; i < len(list)+1; i++ {
var r int
//Zufällige Generierung
for {
r = rand.Intn(len(list))
if !contains(slice, r) {
slice = append(slice, r)
break
}
}
fmt.Printf("%v ", list[r])
if i%parse == 0 {
fmt.Println("")
}
}
}
func contains(s []int, e int) bool {
for _, v := range s {
if e == v {
return true
}
}
return false
}
huyu amana kaho asahi toru
kogane kiriko mano rinze meguru
hiori mitsumine sakuya higuchi jyuri
natsuha tenka chiyuki pya choko
mei mmm hinana
https://gawawa124.hatenablog.com/entry/2015/04/08/193237
https://takeshiyako.blogspot.com/2015/10/go-lang-rand.html
Recommended Posts