Develop
2013.04.23 15:07
[c] 로또(Lotto) 번호 생성기
조회 수 7191 댓글 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
-
프로그램 문서 관리 (Doxygen)
-
프로그래밍에서 foo, bar 함수의 유래
-
프로그래밍 소스 관련 사이트..
-
페이팔에서 돈 찾기 (Paypal withdraw)
-
캘리포니아 운전면허 족보
-
최근 논문 자료 (2011/01/03, 만현형한테 보낸거..)
-
참고하고 지울 자료.. 집에서 바야지.. ㅋㅋ
-
정리할 자료.
-
자주 쓰는 Docker 명령어 alias
-
이어서 작업할 내용~
-
웹페이지 성능 테스트 툴 설명
-
알고리즘 성능분석