"로또번호 생성"의 두 판 사이의 차이

 
(사용자 2명의 중간 판 9개는 보이지 않습니다)
1번째 줄: 1번째 줄:
[[분류: 랜덤]]
;로또번호 생성, 로또 숫자 생성
;함수 genLottoNums
;함수 generateLottoNumbers
;함수 generateLottoNumbers
==Bash==
[[category: Bash]]
<syntaxhighlight lang='Bash' run>
shuf -i 1-45 -n6
</syntaxhighlight>
<syntaxhighlight lang='Bash' run>
shuf -i 1-45 -n6 | xargs -n6
</syntaxhighlight>


==PHP==
==PHP==
[[category: PHP]]
[[category: PHP]]
<source lang='php'>
<syntaxhighlight lang='php' run>
$nums = range(1,46);
$nums = range(1,46);
shuffle($nums);
shuffle($nums);
array_splice($nums, 6);
array_splice($nums, 6);
print_r($nums);
print_r($nums);
// Array
</syntaxhighlight>
// (
//    [0] => 34
//    [1] => 17
//    [2] => 40
//    [3] => 5
//    [4] => 39
//    [5] => 14
// )
</source>


==같이 보기==
==같이 보기==
*[[함수 range]]
*[[함수 range]]
*[[랜덤 패스워드 생성]]
*[[로또 당첨확률 계산]]
*[[로또 당첨확률 계산]]
*[[로또]]

2022년 9월 18일 (일) 12:52 기준 최신판

로또번호 생성, 로또 숫자 생성
함수 genLottoNums
함수 generateLottoNumbers

1 Bash[ | ]

shuf -i 1-45 -n6
shuf -i 1-45 -n6 | xargs -n6

2 PHP[ | ]

$nums = range(1,46);
shuffle($nums);
array_splice($nums, 6);
print_r($nums);

3 같이 보기[ | ]

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