Develop
2013.04.23 15:07
[c] 로또(Lotto) 번호 생성기
조회 수 8281 댓글 0
첨부 '1' |
---|
단, 6번의 루프로 해결 버전 입니다 >0<
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
int ball[46] ={ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46 };
int get_number(void){
return (int)(rand()) % 45 + 1;
}
int main(void){
int i, idx, tmp;
srand((unsigned)time(NULL) * (unsigned)getpid());
for(i=0; i<6; i++){
idx = get_number();
// ball의 인덱스와 ball의 i의 값을 바꾸어 줍니다.
tmp = ball[idx];
ball[idx] = ball[i];
ball[i] = tmp;
}
printf("oops : %d %d %d %d %d %d\n", ball[0], ball[1], ball[2], ball[3], ball[4], ball[5]);
return 0;
}
출처 : http://myohan.egloos.com
번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|---|
625 | Develop | [c] OpenGL 직사각형(2D) 크기 확대/축소 | hooni | 2003.04.23 | 10088 |
624 | Develop |
[c][java] 주사선 채우기 알고리즘(scan line filling algorithm) 구현
![]() |
hooni | 2013.04.23 | 10038 |
623 | Develop |
[c][cpp] mfc, win32api, 예제 소스 대박 모음~
![]() |
hooni | 2013.04.23 | 10026 |
622 | Develop | [c] OpenGL 마우스 이벤트 | hooni | 2003.04.23 | 10023 |
621 | Develop |
[java] 채팅창 처럼.. swing..
![]() |
hooni | 2013.04.23 | 9998 |
620 | Develop |
[c] 컴파일러 DFA구현^^ 입력 받아 실행
4 ![]() |
hooni | 2003.04.23 | 9977 |
619 | System/OS | [linux] man 명령어 뽀개기.. | hooni | 2003.04.23 | 9956 |
618 | Develop | [c] Unix Domain Socket 을 이용한 IPC | hooni | 2013.04.23 | 9953 |
617 | System/OS | [linux] 간단한 find 명령어 설명(업데이트 해야 함) | hooni | 2013.04.23 | 9945 |
616 | Develop |
사이버보안실무 발표자료 (2017.06.08)
![]() |
hooni | 2017.06.05 | 9939 |
615 | Develop |
[c++] 중복실행 방지(Mutex;뮤텍스 ) 샘플 소스.. ㅋㅋ
![]() |
hooni | 2013.04.23 | 9929 |
614 | Develop | [c] 이진트리(binary tree)의 운행.. | hooni | 2003.04.23 | 9929 |