码迷,mamicode.com
首页 > 编程语言 > 详细

c++11:copy_n

时间:2014-10-13 17:35:29      阅读:202      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   io   os   for   sp   div   log   

copy_n:

Copies exactly count values from the range beginning at first to the range beginning at result, if count>0.

从源处拷贝n个数到目标处

  1 #include <iostream>
  2 #include <vecotr>
  3 #include <list>
  4 #include <algorithm>
  5 
  6 using namespace std;
  7 
  8 int main()
  9 {
 10     int str[] = { 1, 2, 3, 4, 5};
 11     int dst[5] {};
 12 
 13     copy_n(str, 5, dst);
 14     for (auto &v : str)
 15         cout << v << " ";
 16     cout << endl;
 17 
 18     vector<int> v_s { 1, 2, 3 ,4, 5};
 19     vector<int> v_d;
 20     list<int> l_d;
 21 
 22     copy_n(v_s.begin(), 5, v_d.begin());
 23     for (auto &v : v_d)
 24         cout << v << endl;
 25 
 26     copy_n(v_s.begin(), 5, l_d.begin());
 27     for (auto &v : l_d)
 28         cout << v << endl;
 29 }

 

c++11:copy_n

标签:style   blog   color   io   os   for   sp   div   log   

原文地址:http://www.cnblogs.com/457220157-FTD/p/4022117.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!