leetcode 566
class Solution {
public:
vector<vector<int>> matrixReshape(vector<vector<int>>& mat, int r, int c) {
int x=0,y=0;
int m=mat.size(),n=mat[0].size();
vector<vector<int>>tam(r,vector<int>(c));
if(m*n!=r*c) return mat;
else
{
for (int x = 0; x < m * n; ++x) {
tam[x / c][x % c] = mat[x / n][x % n];
}
}
return tam;
}
};
END