文章
49
粉丝
90
获赞
9
访问
27.3k
0度就是没变
90度是关键
180度就是转2次90度
270度就是转3次90度
#include<iostream>
#include<vector>
using namespace std;
/*输出一个2维数组*/
void print(vector<vector<int>>& a)
{
int n = a.size();
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
{
cout << a[i][j] << " ";
}cout << endl;
}
}
/*旋转90度*/
vector<vector<int>> reverse_90(vector<vector<int>> a)
{
int n = a.size();
vector<vector<int>> b(n, vector<int>(n));
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
{
b[i][j] = a[n - j - 1][i];
}
return b;
}
int main()
{
int n;
while (cin >> n)
{
vector<vector<int>> a(n, vector<int>(n));
vector<vector<int>> b(n, vector<int>(n));
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
{
cin >> a[i][j];
}
for (int i = 0; i < n; i++)
for (in...
登录后发布评论
暂无评论,来抢沙发