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 | 31 |
Tags
- arduino compiler
- Arduino
- 아두이노 소스
- 통계학
- 라인트레이서
- Array
- Stack
- priority_queue
- vector
- list
- Algorithm
- 시스템프로그래밍
- Visual Micro
- queue
- 아두이노 컴파일러
- 아두이노
- 컴퓨터 그래픽스
- set
- C언어
- map
- LineTracer
- WinAPI
- c++
- Deque
- 운영체제
- stl
- directx
- 수광 소자
- html
- 자료구조
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 |