SHARE
TWEET

Cau2_XoayMang2Chieu

mxn12 Feb 17th, 2020 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void rotate(int arr[][3], int n)
  5. {
  6.     int tmp[3][3];
  7.     for (int i = 0; i < n; i++) {
  8.         for (int j = 0; j < n; j++) {
  9.             tmp[j][n - 1 - i] = arr[i][j];
  10.         }
  11.     }
  12.  
  13.     for (int i = 0; i < n; i++) {
  14.         for (int j = 0; j < n; j++) {
  15.             cout << tmp[i][j] << " ";
  16.         }
  17.         cout << endl;
  18.     }
  19. }
  20.  
  21. int main() {
  22.     int arr[3][3] = { {1,2,3},{4,5,6},{7,8,9} };
  23.  
  24.     rotate(arr, 3);
  25. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top