Turbo-C
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
터보-C 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
Lua 게시판
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C/C++ Q/A
[3316] srand로 seed값주고 rand했는데, 계속 같은 값이 나오네요...
로터스 [] 2244 읽음    2004-04-17 07:41
소스는 아래와 같구요...
이대로 하면 컴파일 할때마다 다른 값이 나와야 할 것 같은데
계속 rand 결과가 같네요.. 왜 그럴까요?

#include <iostream>
#include <vector>
#include <cstdlib>

using namespace std;

void main()
{
    const int seq_size = 18;
    const int seq_cnt = 6;

    vector<int> fibonacci, lucas, pell, triangular, square, pentagonal;

    vector<int> *seq_addrs[ seq_cnt ] = {
        &fibonacci, &lucas, &pell,
        &triangular, &square, &pentagonal
    };

    vector<int> *current_vec = 0;



    srand( seq_cnt );
    int seq_index = rand() % seq_cnt;
    current_vec = seq_addrs[ seq_index ];

    cout << seq_index;


   

}


+ -

관련 글 리스트
3316 srand로 seed값주고 rand했는데, 계속 같은 값이 나오네요... 로터스 2244 2004/04/17
4398     Re:srand로 seed값주고 rand했는데, 계속 같은 값이 나오네요... 최준호.스페로 2325 2004/04/17
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.