로또번호 생성

Jmnote bot (토론 | 기여)님의 2020년 11월 2일 (월) 02:36 판 (봇: 자동으로 텍스트 교체 (-source +syntaxhighlight))
로또번호 생성, 로또 숫자 생성
함수 genLottoNums
함수 generateLottoNumbers

1 Bash

shuf -i 1-45 -n6
# 30
# 35
# 43
# 8
# 4
# 44
shuf -i 1-45 -n6 | xargs -n6
# 1 40 17 15 29 16

2 PHP

$nums = range(1,46);
shuffle($nums);
array_splice($nums, 6);
print_r($nums);
// Array
// (
//     [0] => 34
//     [1] => 17
//     [2] => 40
//     [3] => 5
//     [4] => 39
//     [5] => 14
// )

3 같이 보기

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}