소스는 아래와 같구요...
이대로 하면 컴파일 할때마다 다른 값이 나와야 할 것 같은데
계속 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;
}
|