C++使用vector

时间:2023-03-09 16:16:53
C++使用vector
#include <iostream>
#include <string>
#include <vector> using namespace std; void show(vector<int> v)
{
for(auto v1 : v){
cout << v1 << endl;
}
} void show2(vector<int> v)
{
for(vector<int>::const_iterator v1 = v.cbegin(); v1 != v.cend(); v1++){
cout << *v1 << endl;
}
} int main()
{
vector<int> int_vec;
for(int i = ; i < ; i++){
int_vec.push_back(i);
} show2(int_vec); //for(vector<int>::iterator t = int_vec.begin(); t != int_vec.end(); t++){
// cout << *t << endl;
//}
/*循环vector*/
//for(auto v : int_vec){
// cout << v << endl;
//}
}