Contents

Develop
2013.04.23 15:07

[c] 로또(Lotto) 번호 생성기

Views 7174 Comment 0
Atachment
Attachment '1'
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
단, 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


?

  1. [c] 마우스 따라다니는 고양이 - 네코95 (WinAPI)

    Date2013.04.23 CategoryDevelop Byhooni Views7944
    Read More
  2. [c] 로또(Lotto) 번호 생성기

    Date2013.04.23 CategoryDevelop Byhooni Views7174
    Read More
  3. [c] 레포트용으로 제출했던 여러 소스코드 모음

    Date2003.04.23 CategoryDevelop Byhooni Views8084
    Read More
  4. [c] 라인수 입력받아 마름모꼴 출력하기..

    Date2003.04.23 CategoryDevelop Byhooni Views6868
    Read More
  5. [c] 디피-헬만 키교환(Diffie–Hellman key exchange) 샘플 코드.. ㅋㄷ

    Date2013.04.23 CategoryDevelop Byhooni Views9110
    Read More
  6. [c] 도스 공격(DoS Attack) 프로그램

    Date2013.04.23 CategoryDevelop Byhooni Views11575
    Read More
  7. [c] 도메인(호스트)으로 IP정보 알아오기.. (nslookup과 비슷)

    Date2013.04.23 CategoryDevelop Byhooni Views6925
    Read More
  8. [c] 도메인 소켓(Unix Domain Socket) UDP

    Date2013.04.23 CategoryDevelop Byhooni Views9282
    Read More
  9. [c] 더블(이중) 연결리스트 예제..

    Date2013.04.23 CategoryDevelop Byhooni Views7470
    Read More
  10. [c] 달팽이 배열? 인지 먼지.. ㅋㅋ

    Date2013.04.23 CategoryDevelop Byhooni Views7128
    Read More
  11. [c] 단어 입력/수정 프로그램 소스

    Date2003.04.23 CategoryDevelop Byhooni Views7016
    Read More
  12. [c] 단기과정[01/24] 정렬 알고리즘

    Date2003.04.23 CategoryDevelop Byhooni Views6955
    Read More
Board Pagination Prev 1 ... 68 69 70 71 72 73 74 75 76 77 ... 98 Next
/ 98