刷题 数字 转置二维矩阵

题目
刷题 数字 转置二维矩阵解题
class Solution {
public:
vector<vector> transpose(vector<vector>& A) {
int row=A.size();
int col=A[0].size();
vector<vector> temp(col,vector(row,0));
for(int i=0;i<row;i++)
{
for(int j=0;j<col;j++)
{
temp[j][i]=A[i][j];
}
}
return temp;
}
};

收获:
1.容器 vector
一维数组定义
vector name(size,initalval可省略);
二位数组定义
vector <vector> name(row,vector(size,initalval可省略))
二维容器数组的行列都可不一样
例如添加一行
name.push_back(vector(10,1))
为某行末尾追加一个元素13
name[i].push_back(13)
2.获取数组行列
array[i][y]
int rows = array.size();//行数
int columns = array[0].size();//列数

疑问:
temp[j][i]=A[i][j];
这样执行就AC
temp[i][j]=A[j][i];
就错误 ?