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

14번째 줄: 14번째 줄:
==PHP==
==PHP==
[[category: PHP]]
[[category: PHP]]
<syntaxhighlight 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
// (
//    [0] => 34
//    [1] => 17
//    [2] => 40
//    [3] => 5
//    [4] => 39
//    [5] => 14
// )
</syntaxhighlight>
</syntaxhighlight>



2022년 9월 17일 (토) 18:45 판

로또번호 생성, 로또 숫자 생성
함수 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 }}