
エントリーの編集

エントリーの編集は全ユーザーに共通の機能です。
必ずガイドラインを一読の上ご利用ください。
Go 言語でスライス/配列をランダムな順番でシャッフルっする ( #go shuffle array / slice / cards example ) - Qiita
記事へのコメント0件
- 注目コメント
- 新着コメント
このエントリーにコメントしてみましょう。
注目コメント算出アルゴリズムの一部にLINEヤフー株式会社の「建設的コメント順位付けモデルAPI」を使用しています

- バナー広告なし
- ミュート機能あり
- ダークモード搭載
関連記事
Go 言語でスライス/配列をランダムな順番でシャッフルっする ( #go shuffle array / slice / cards example ) - Qiita
// https://golang.org/pkg/math/rand/ package main import ( "fmt" "math/rand" "time" ) func main()... // https://golang.org/pkg/math/rand/ package main import ( "fmt" "math/rand" "time" ) func main() { cards := []string{"2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A"} cards4 := []string{} for i := 0; i < 4; i++ { cards4 = append(cards4, cards...) } rand.Seed(time.Now().UnixNano()) rand.Shuffle(len(cards4), func(i, j int) { cards4[i], cards4[j] = cards4[j], cards4[i] }) fmt.Println