C++ Clean Solution
\nclass Solution {\npublic:\n    vector<vector<int>> matrixReshape(vector<vector<int>>& nums, int r, int c) {\n        int m = nums.size();\n        if (m == 0)
```\nclass Solution {\npublic:\n    vector<vector<int>> matrixReshape(vector<vector<int>>& nums, int r, int c) {\n        int m = nums.size();\n        if (m == 0){\n            return nums;\n        }\n        \n        int n = nums[0].size();\n        \n        if (m * n != r * c) return nums;\n        \n        \n        vector<vector<int>> res (r, vector<int> (c));\n        \n        int row = 0, col = 0;\n        for (int i = 0; i < m; i++){\n            for (int j = 0; j < n; j++){\n                res[row][col] = nums[i][j];\n                col += 1;\n                \n                \n                if (col == c){\n                    row += 1;\n                    col = 0;\n                }\n            }\n           \n        }\n        \n        return res;\n    }\n};\n```\n
['C', 'C++']