'LOTTO'에 해당되는 글 1건

  1. 2015.02.07 Lotto

Lotto

Programming/C / C++ 2015. 2. 7. 19:02
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

////////////////////////////////////////////////////////////////////////////////
// Title : 로또 프로그램
// Author : 최민혁
// Revision : 2006. 5. 30 First implementation
///////////////////////////////////////////////////////////////////////////////
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main( void )
{
    int number[45] = {  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 };
    int result[6] = { 0 };
    int i, temp;
    int count = 0;

 

    srand( time(NULL) );

 

    while( count < 6 )
    {
         temp = rand() % 45 + 1;
         for( i = 0; i < 45; i++ )
         {
             if( number[i] == temp )
             {
                 result[count] = temp;
                 number[i] = 0;
                 count++;
             }
         }  
    }

 

    for( i = 0; i < 6; i++ )
        printf( "Making Number %d : %d\n", i + 1, result[i] );

 

    printf( "Enter 키를 누르면 종료됩니다" );

 

    while( getchar() != '\n' )
        continue;

 

    return 0;
}

 

대학시절 강의시간에 심심해서 수업 안듣고 짜본거 ㅋ

이걸로 5등 몇번 당첨됐었다 ㅋㅋ

'Programming > C / C++' 카테고리의 다른 글

XOR Swap  (0) 2015.02.07
struct tm  (0) 2015.02.07
Quick Cast  (0) 2015.02.07
_strtime  (0) 2015.02.07
소수점 둘째자리이하 자르기  (0) 2015.02.07
Posted by 역시인생한방
,