# include <iostream>
# include <vector>
using namespace std;
void rotateAclockwise90Vector(vector < vector < int >> & A, int N)
{
if (N < 2)
{
return;
}
bool flag = true;
while (flag)
{
if (A[0][0] < A[0][N-1] &&
A[0][0] < A[N-1][0] &&
A[N-1][0] < A[N-1][N-1] &&
A[0][N-1] < A[N-1][N - 1])
{
break;
}
for (int i = 0; i < N; i++){
for (int j = i; j < N; j++){
int t = A[i][j];
A[i][j] = A[j][i];
A[j][i] = t;
}
}
int i = 0;
int j = N - 1;
while (i < j){
for (int k = 0; k < N; k++){
int t = A[i][k];
A[i][k] = A[j][k];
A[j][k] = t;
}
i++;
j--;
}
}
}
int main()
{
int N;
vector < vector < int >> B;
cin >> N;
for (int i = 0; i < N; i++)
{
vector < int > cur;
for (int j = 0; j < N; j++){
int c = 0;
cin >> c;
cur.push_back(c);
}
B.push_back(cur);
}
rotateAclockwise90Vector(B, N);
for (int i = 0; i < N; i++)
{
for (int j = 0; j < N; j++){
cout << B[i][j] << " ";
}
cout << endl;
}
}
top of page
Recent Posts
See All#include<iostream> #include <vector> #include <algorithm> #include <cmath> #include <stack> using namespace std; int main() { int r, c,...
s1 = input() s2 = input() silly = '' silly_o = '' quiete = '-' i = 0 j = 0 while i < len(s1) and j < len(s2): if s1[i] != s2[j]: if...
#include<iostream> #include <vector> #include <algorithm> #include <cmath> using namespace std; bool rowcom(pair<int, int> a, pair<int,...
bottom of page
Comments