获取、修改、追加、清空、
#include <iostream>
#include <vector>
using namespace std;
int main()
{
vector <int> a1_ (3);
vector <int> a2_ (3, 7);
vector <int> a3_ {1, 2, 3, 4, 5, 6, 7, 8, 9};
a1_.at(0);
a3_[8] = 0;
a3_.push_back(10);
cout << "获取:" << a1_.at(0) << a1_.at(1) << a1_.at(2) << endl;
cout << "查看:" << a2_.at(0) << a2_.at(1) << a2_.at(2) << endl;
cout << "修改为零:" << a3_.at(8) << endl;
cout << "追加:" << a3_[9] << endl;
vector <int> a4_ {1, 2, 3, 4, 5, 6, 7, 8, 9};
cout << "清空前:" << a4_.size() << "内容:" << endl;
for (auto i:a4_)
{
cout << i ;
}
a4_.clear();
cout << endl << "清空后:" << endl;
for (auto i:a4_)
{
cout << i ;
}
cout << "=======================" << endl;
vector <vector<int>> a4
{
{1, 2, 3},
{4, 5, 6},
{7, 8, 9}
};
cout << "维度:" << a4.size() << endl;
cout << a4.at(0).at(2) << endl;
return 0;
}