1.vector
头文件#include <vector>
常见的方法有vector.clear() ; vector.size() ; vector.empty();
遍历输出vector:
#include <iostream> #include <vector> using namespace std; int main(){ vector<int> a({1,2,3,4}); for(int i = 0 ; i < a.size() ; i++) cout<<a[i]<<" "; cout<<endl; for(vector<int>::iterator i = a.begin() ; i!=a.end() ; i++) cout<<*i<<" "; cout<<endl; for(auto i = a.begin() ; i!= a.end() ; i++) cout<<*i<<" "; cout<<endl; }