赞
踩
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
vector<vector<double>> test()
{
vector<vector<double> > array2D(5, vector<double>(3));
array2D[2][2] = 10.0;
cout << "array2D[2][2]:" << array2D[2][2] << endl;
return array2D;
}
int main()
{
cout << "********************二维向量*************************" << endl;
vector<vector<int>> aa;
vector<vector<double>> array2D(5, vector<double>(3));
array2D[1][2] = 6.0;
cout << "array2D[1][2]:" << array2D[1][2] << endl;
//array2D[1][3] = 7.0;
// 设置容器大小(HEIGHT x WIDTH)
array2D.resize(5);
for (int i = 0; i < 3; ++i)
array2D[i].resize(3);
//放入一些数据
array2D[1][2] = 6.0;
array2D[1][1] = 5.5;
cout << "array2D的行数:" << array2D.size() << endl;
cout << "array2D的列数:" << array2D[0].size() << endl;
vector<vector<double>> test2;
test2 = test();
cout << "test2[2][2]:" << test2[2][2] << endl;
cout << "test2的行数:" << test2.size() << endl;
cout << "test2的列数:" << test2[2].size() << endl;
system("pause");
return 0;
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。