Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- Visual Micro
- Arduino
- 자료구조
- 아두이노 소스
- Algorithm
- stl
- 아두이노 컴파일러
- set
- map
- queue
- directx
- 통계학
- 운영체제
- WinAPI
- LineTracer
- priority_queue
- 라인트레이서
- 시스템프로그래밍
- 수광 소자
- Array
- Stack
- arduino compiler
- vector
- Deque
- 컴퓨터 그래픽스
- c++
- html
- 아두이노
- list
- C언어
Archives
- Today
- Total
Kim's Programming
Algorithm - generate() 본문
원형)
1 2 3 | //기본형 template <class ForwardIterator, class Generator> void generate (ForwardIterator first, ForwardIterator last, Generator gen); | cs |
의미)
[Iterator first, Iterator last)사이에 있는 원소들에 gen으로 생성된 값을 할당합니다.
소스)
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 | #include<iostream> #include<algorithm> #include<vector> #include<ctime> #include<cstdlib> void Print(const std::vector<int>& target) { for (std::vector<int>::const_iterator iterPos = target.begin(); iterPos != target.cend(); iterPos++) std::cout << *iterPos << ' '; std::cout << std::endl; } int Function() { return std::rand() % 100; } void main() { std::srand(static_cast<unsigned int>(std::time(nullptr))); std::vector<int> vector = { 1,2,3,4,5,6,7,8,9 }; std::vector<int>::iterator iter; Print(vector); std::generate(vector.begin(), vector.end(), Function); Print(vector); } | cs |
리턴값)
없음
결과)
'STL - Algorithm > Algorithm - Modifying' 카테고리의 다른 글
Algorithm - remove() (0) | 2017.07.13 |
---|---|
Algorithm - generate_n() (0) | 2017.07.12 |
Algorithm - fill_n() (0) | 2017.07.12 |
Algorithm - fill() (0) | 2017.07.12 |
Algorithm - replace_copy_if() (0) | 2017.07.12 |