Guest User

Untitled

a guest
Aug 10th, 2018
63
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void Matrix::rotateAR() {
  2.   int cols = this->cols, rows = this->rows;
  3.   int size = (cols > rows) ? cols : rows;
  4.  
  5.   char** oldData = this->data;
  6.  
  7.   char** data = new char*[size];
  8.   for (int x = 0; x < size; x++) {
  9.     data[x] = new char[size];
  10.     for (int y = 0; y < size; y++)
  11.       data[x][y] = ' ';
  12.   }
  13.  
  14.   this->cols = size;
  15.   this->rows = size;
  16.  
  17.   for (int x = 0; x < cols; x++)
  18.     for (int y = 0; y < rows; y++)
  19.       data[x][y] = oldData[x][y];
  20.  
  21.   this->data = data;
  22.  
  23.   rotate(1); //Transposes and reverses columns
  24.  
  25.   if (cols > rows) {
  26.     //Remove enough columns from the left
  27.   } else {
  28.     //Remove enough bottom rows
  29.   }
  30.  
  31.   //Debug; checking if matrix resized correctly at the end.
  32.   for (int x = 0; x < this->cols; x++)
  33.     for (int y = 0; y < this->rows; y++)
  34.       if (this->data[x][y] == ' ')
  35.         this->data[x][y] = 'o';
  36. }
RAW Paste Data