#include <iostream> using namespace std; int main() { int row, column; int sz; cout << "Enter the size of matrix, 2 * 2 or 3 * 3" << endl; scanf("%d%*c%d", &row, &column); sz = row * column; int **a = new int *[row]; for (int i = 0; i < row; i++) { a[i] = new int[column]; } //cout << "Please enter " << sz << " element of matrix:" << endl; a[3][3] = {{6, 1, 1}, {4, -2, 5}, {2, 8, 7}}; }
error: expected expression
a[3][3] = {{6, 1, 1}, {4, -2, 5}, {2, 8, 7}};
我想知道为什么这样做不对?我这样做的理由是a[3] = {1, 2, 3};
这样做是不是不是初始化,因为我已经动态分配了内存,已经创建了数组,所以a[3][3]= {{6, 1, 1}, {4, -2, 5}, {2, 8, 7}};是赋值多个值到一个数组元素a[3][3]
largeQ
12345678_0001
相关分类