프로그래밍
로또 완전 조합 루프문 (c/c++)(로또함수)
잇힝2012
2014. 8. 3. 16:17
lotto000.cpp
#include <stdio.h>
int main(int argc, char *argv[])
{
int count=0;
for(int a=1; a<=40; a++) {
for(int b=a+1; b<=41; b++) {
for(int c=b+1; c<=42; c++) {
for(int d=c+1; d<=43; d++) {
for(int e=d+1; e<=44; e++) {
for(int f=e+1; f<=45; f++) {
count++;
// 로또 8145060 조합 루프
// a,b,c,d,e,f 가 로또 번호
}}}}}}
printf("count = %d\n", count); // 결과: 8145060
getchar();
return 0;
}
로또 번호 1,2,3,4,5,6 부터 40,41,42,43,44,45 까지 순차적으로 8145060 회 순환하는 루프문 입니다.
a,b,c,d,e,f 가 로또 번호를 의미합니다.