题目描述
解题思路
写一个具体的矩阵,看一下其坐标变化的规律(外循环是列,内循环是行)
代码实现
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 1010;
int m, n;
int a[N][N];
int main()
{
cin >> m >> n;
for (int i = 0; i < m; i ++)
{
for (int j = 0; j < n; j ++)
{
cin >> a[i][j];
}
}
for (int i = n - 1; i >= 0; i --) //当一列循环完,再换一列,列从大到小开始迭代
{
for (int j = 0; j < m; j ++)
{
cout << a[j][i] << " ";
}
cout << endl;
}
return 0;
}