C++——Vector

 1 #include "opencv2/objdetect.hpp"                                                                                   
 2 #include "opencv2/videoio.hpp"
 3 #include "opencv2/highgui.hpp"
 4 #include "opencv2/imgproc.hpp"
 5 #include <iostream>
 6 #include <stdio.h>
 7 #include <stdlib.h>
 8 #include <conio.h>
 9 using namespace std;
10 using namespace cv;
11 int main()
12 {
13     std::vector<int> vec;
14     vec.push_back(1);
15     vec.push_back(2);
16     vec.push_back(3);
17     vec.push_back(4);
18     cout<<vec[3]<<endl;
19     vector<int>::iterator it;
20     for(it=vec.begin();it!=vec.end();it++){
21             cout<<"vector:"<<*it<<endl;
22     }
23     vec.insert(vec.begin()+3,9);
24     cout<<vec[3]<<endl;
25     vec.erase(vec.begin()+3);
26     cout<<vec[3]<<endl;
27     cout<<vec.size()<<endl;
28 
29     getch();
30     return 0;
31 }

 

 

posted on 2019-04-18 23:12  AI大道理  阅读(298)  评论(0编辑  收藏  举报

导航