My Computer Programs

(Go) 로또 번호 생성

steloflute 2012. 8. 27. 22:51

package main

import (
 "fmt"
 "math/rand"
 "time"
)

func main() {
 r := map[int]bool{}
 rand.Seed(time.Now().UnixNano())

 for len(r) < 6 {
  r[rand.Intn(45)+1] = true
 }

 for x := range r {
  fmt.Println(x)
 }
}


 

lotto.exe

 

'My Computer Programs' 카테고리의 다른 글

(Python) KOSPI200 시세 얻기  (0) 2012.08.29
(Python) 좌우열기 인쇄 페이지 재설정  (0) 2012.08.29
(Javascript) 로또 번호 생성  (0) 2012.08.27
(Python) 로또 번호 생성  (0) 2012.08.26
(Java) 로또 번호 생성  (0) 2012.08.26