Code Archive/C++

STL. Set 로또 예제

쌍큐 2018. 2. 1. 10:49

#include <iostream>

#include <set>

#include <ctime>

#include <cstdlib>

using namespace std;


int main(void)

{

set<int> s;

srand((unsigned int)time(NULL));


for(int i=0;i<5;i++)

{

while(s.size()<6) 

s.insert(rand() % 45 + 1);


set<int>::iterator it;

for(it=s.begin();it!=s.end();it++)

cout << *it << " ";

cout << endl;

s.clear();

}

return 0;

}

'Code Archive > C++' 카테고리의 다른 글

TV 클래스 - 클래스 작성하기  (0) 2018.04.17
STL. map 기본 예제  (0) 2018.02.01
STL. Set 기본 예제  (0) 2018.02.01
STL. List 기본 예제  (0) 2018.02.01
Step6. 생성자와 소멸자  (0) 2018.01.24