File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11add_executable (vector1 vector1.cpp )
22add_executable (vector2 vector2.cpp )
3- add_executable (vector3 vector3.cpp )
3+ add_executable (vector3 vector3.cpp )
4+ add_executable (vector4 vector4.cpp )
Original file line number Diff line number Diff line change 1+ //
2+ // Created by zing on 6/14/2020.
3+ //
4+
5+
6+ #include < vector>
7+ #include < iostream>
8+
9+ using namespace std ;
10+
11+ void printVector (vector<int > &v) {
12+
13+ for (vector<int >::iterator it = v.begin (); it != v.end (); it++) {
14+ cout << *it << " " ;
15+ }
16+ cout << endl;
17+ }
18+
19+ void test01 () {
20+ vector<int > v1; // 无参构造
21+ for (int i = 0 ; i < 10 ; i++) {
22+ v1.push_back (i);
23+ }
24+ printVector (v1);
25+
26+ vector<int > v2 (v1.begin (), v1.end ());
27+ printVector (v2);
28+
29+ vector<int > v3 (10 , 100 );
30+ printVector (v3);
31+
32+ vector<int > v4 (v3);
33+ printVector (v4);
34+ }
35+
36+ int main () {
37+ test01 ();
38+ return 0 ;
39+ }
You can’t perform that action at this time.
0 commit comments