Code First Fractional group: 15th matrix Flip (image rollover)
First of all, pure simulation, from the outside to the inner lap of the turn, but this method is too slow.
For example, first flip along the diagonal and then flip it one time along the horizontal midline.
Source
#include <iostream>#include<vector>using namespacestd;//Reference type parametervoidSwapint&n,int&L) { inttemp=N; N=m; M=temp;}//pointer type parametervoidSWAP1 (int*a,int*b) { inttemp; Temp= *A; *a = *b; *b =temp; }//swap function with addition and subtractionvoidSWAP2 (int&a,int&b) {a= A +b; b= A-b; A= A-b;}//swap function using an XOR operationvoidSWAP3 (int&a,int&b) {a= a^b; b= a^b; A= a^b;}voidRotateinta[][3],intN) { //int i,j; for(inti =0; I < n; i++) { for(intj =0; J < N-i; J + +) {Swap (A[i][j],a[n-j-1][n-i-1]); } } for(inti =0; I < n/2; i++) { for(intj =0; J < N; J + +) {Swap (A[i][j],a[n-i-1][j]); } }}voidRotate2 (vector<vector<int>>&matrix) { Const intn =matrix.size (); for(inti =0; I < n; i++) {//invert diagonally along the diagonal for(intj =0; J < N-i; J + +) {swap (matrix[i][j], matrix[n-1-J][n-1-i]); } } for(inti =0; I < n/2; i++) {//reverse along the horizontal midline for(intj =0; J < N; J + +) {swap (matrix[i][j], matrix[n-1-i] [j]); } }}intMain () {inta[3][3]={{1,2,3},{4,5,6},{7,8,9}}; Rotate (A,3); for(inti =0; I <3; i++) { for(intj =0; j<3; J + +) {cout<<a[i][j]<<Endl; }} vector<vector<int>> matrix={{1,2,3},{4,5,6},{7,8,9}}; Rotate2 (matrix); for(inti =0; I <3; i++) { for(intj =0; j<3; J + +) {cout<<matrix[i][j]<<Endl; } } /*vector<int> row1 = {n/a}; Vector<int> row2 = {4,5,6}; Vector<int> row3 = {7,8,9}; Vector<vector<int>> Matrix; Matrix.push_back (ROW1); Matrix.push_back (ROW2); Matrix.push_back (ROW3); Rotate2 (matrix); int n = matrix.size (); for (int i = 0;i < n;i++) {for (int j = 0;j < n;j++) {cout<<matrix[i][j]<<endl; } }*/ return 0;}
Code First Fractional group: 15th matrix Flip (image rollover)