vector创建二维数组 初始化二维数组 vector<vector <int> > ivec(n ,vector<int>(m)); //n*m的二维vector vector<vector <int> > ivec(n , vector<int>(m, 0)); //n*m的二维vector,所有元素为0 动态创建m*n的二维 方法一: vector<vector <int> > ivec; ivec.resize(n); for(int i = 0; i < n; i++) ivec[i].resize(m); 方法二: vector<vector <int> > ivec; ivec.resize(n, vector<int>(m)); 动态创建二维数组a[n][m] C语言版: #include<malloc.h> int **a = (int **)malloc(n *sizeof(int *)); for(int i = 0; i < n; i++) a[i] = (int *)malloc(m *sizeof(int)); C++版: int **a = new int *[n]; for(int i = 0; i < n; i++) a[i] = new int[m];