#include <stdio.h>
#include <vector>
using namespace std;
vector<vector<int> > testVector(int n);
int main(void)
{
int i,j;
int n=6;
vector<vector<int> > table;
table=testVector(n);
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
printf("%2d",table[i][j]);
printf("\n");
}
return 0;
}
vector<vector<int> > testVector(int n)
{
int i,j;
vector<int> line;
vector< vector< int> > table;
for(i=0;i<n;i++)
{
table.push_back(line);
for(j=0;j<n;j++)
{
table[i].push_back(1);
}
}
table[0][0]=2;
table[0][1]=2;
return table;
}
vector实现动态二维数组
最新推荐文章于 2024-03-24 14:22:42 发布