class Solution {
public:
vector[HTML_REMOVED] printMatrix(vector[HTML_REMOVED] > matrix) {
vector[HTML_REMOVED] res;
if(matrix.empty()) return res;
int m = matrix.size();
int n = matrix[0].size();
int floor = (min(m, n) + 1)/ 2;//统计矩阵有几层
int t = 0;
while (t < floor) {
for (int i = t; i < n - t; i) res.push_back(matrix[t][i]);
for (int i = t + 1; i < m - t; i) res.push_back(matrix[i][n - 1 - t]);
for (int i = n - 2 - t; (i >= t) && (m - t -1!=t); i–) res.push_back(matrix[m - 1 - t][i]);
for (int i = m - 2 - t; (i >= t + 1) && (n - t -1!=t); i–) res.push_back(matrix[i][t]);
t++;
}
}
};