1 #include <iostream>
  2 #include <vector>
  3 #include <time.h>
  4 using namespace std;
  5 
  6 
  7 int main()
  8 {
  9 	// 랜덤 돌릴 범위의 모든 숫자를 저장한다.
 10 	vector<int> LottoNum;
 11 	for (int i = 0; i < 50; ++i)
 12 		LottoNum.push_back((i+1));
 13 
 14 	vector<int> ResultLottoNum;  // 램덤 후 결과값 담을 벡터
 15 	int NumRand = 0;
 16 
 17 	srand((unsigned)time(0));
 18 
 19 	for (int i = 0; i < 25; ++i)
 20 	{
 21 		vector<int>::iterator vcItr;
 22 
 23 		int SelectRandNum = 0;
 24 		SelectRandNum = rand()%LottoNum.size();  //랜덤
 25 
 26 		vcItr = LottoNum.begin() + SelectRandNum; // iterator에 램덤 위치 값 가르키도록 지정.
 27 
 28 		NumRand = *vcItr;   //값을 저장.
 29 		cout << NumRand << " / ";
 30 
 31 		if ((i+1)%5 == 0)
 32 			cout << endl;
 33 		ResultLottoNum.push_back(NumRand);  //최종 결과값 저장 벡터에 데이터 넣기.
 34 
 35 		LottoNum.erase(vcItr);     // 중복되지 않도록 삭제 처리.
 36 	}
 37 	return 0;
 38 }
 39 
 40 


 

+ Recent posts