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
- c++
- LineTracer
- Deque
- 컴퓨터 그래픽스
- Visual Micro
- Stack
- 라인트레이서
- WinAPI
- 통계학
- 수광 소자
- arduino compiler
- list
- html
- C언어
- 아두이노 컴파일러
- 자료구조
- stl
- Algorithm
- 시스템프로그래밍
- 운영체제
- vector
- 아두이노 소스
- 아두이노
- Array
- map
- priority_queue
- set
- Arduino
- queue
- directx
Archives
- Today
- Total
Kim's Programming
Algorithm - copy_n() 본문
원형)
1 2 3 | //기본형 template <class InputIterator, class Size, class OutputIterator> OutputIterator copy_n (InputIterator first, Size n, OutputIterator result); | cs |
의미)
Iterator first부터 n개의 원소를 Iterator result위치 부터 복사합니다.
소스)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | #include<iostream> #include<algorithm> #include<vector> 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; } void main() { int dataArray[] = { 1,3,5,7,9,11,13,15 }; std::vector<int> vector(8); std::copy_n(dataArray, 6, vector.begin()); Print(vector); } | cs |
리턴값)
복사된 데이터의 가장 마지막을 가리키는 Iterator를 리턴합니다.
결과)
'STL - Algorithm > Algorithm - Modifying' 카테고리의 다른 글
Algorithm - swap_ranges() (0) | 2017.07.12 |
---|---|
Algorithm - swap() (0) | 2017.07.12 |
Algorithm - copy_backward() (0) | 2017.07.12 |
Algorithm - copy_if() (0) | 2017.07.12 |
Algorithm - copy() (0) | 2017.07.11 |