CCF 201503-1 图像旋转(C++)
作者:互联网
好像旋转矩阵有更好的做法,但是我觉得这样也足够了,如果需要更好的做法,大家得自己在去找一下。
我主要是找了下规律,然后做出来的
#include<iostream>
#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
int num1[1005][1005];
int num2[1005][1005];
int n, m;
int main()
{
cin >> n >> m;
for (int i = 0; i < n; i++){
for (int j = 0; j < m; j++){
scanf("%d", &num1[i][j]);
}
}
for (int i = 0; i < n; i++){
num2[m-1][i]=num1[i][0];
for (int j = 1; j < m; j++){
num2[m-1-j][i]=num1[i][j];
}
}
for (int i = 0; i < m; i++){
for (int j = 0; j < n; j++){
printf("%d ", num2[i][j]);
}
printf("\n");
}
return 0;
}
标签:include,num1,num2,int,C++,++,201503,1005,CCF 来源: https://www.cnblogs.com/understanding-friends/p/16642746.html