c++ - How to store symmetries of a Polyomino using pointers-to-pointers? -


okay i'm working on coding discrete tiling problem. storing object called polyomino so:

 pointer = new int*[h];  p_0 = new int*[h];  p_1 = new int*[h];  p_2 = new int*[w];  p_3 = new int*[w];  p_4 = new int*[w];  p_5 = new int*[h];  p_6 = new int*[w];   (i=0 ; < h ; i++)      pointer[i] = new int[w];      p_0[i] = new int[w];      p_1[i] = new int[w];      p_5[i]=new int[w];       }       for(i=0 ; < w ; i++){      p_2[i]=new int[h];      p_3[i]=new int[h];      p_4[i]=new int[h];      p_6[i]=new int[h];      }    (i=0; i<h ; i++){      for(j=0; j<w ; j++){         cout << "what " << i+1;           cout << ", " << j+1;            cout << endl;              cin >> k;               if(k != 0)                 pointer[i][j]=1;                        else                   pointer[i][j]=0;        }    }  

then generating 8 possible orientations (the group of symmetries of square) , storing them 7 other double pointers. wondering if there way can make array of size 8 holds address each 1 of double pointers.

if this, make life lot easier when checking board tiled empty spaces , placing them. like:

         orientation[8];          orientation[0]=pointer;          orientation[1]=p_0;          orientation[2]=p_1;          orientation[3]=p_2;          orientation[4]=p_3; 

and on. problem there 2 different sizes; 1 being hxw , other being wxh. first though like:

     int** orientation;      orientation = new int*[8]       for(i=0;i<8<;i++)        orientation[i]=new int*[h*w]; 

thanks bunch in advance.

the elements of array stored @ consecutive places in memory, can addresses , computations on :

int arr[] = { 0, 1, 2, 3, 4, 5 }; int* = &arr[0]; // address of beginning of array (i.e index 0) int* b = + 3;   // address of index 3, behind scene + (3 * sizeof(int))  cout << "index 0 : " << *a << endl; cout << "index 3 : " << *b << endl << endl;  int d = 0, e = 1, f = 2; int* arr2[] = { &d, &e, &f }; // array of pointers int** address = &arr2[1];     // pointer pointer int*** address_of_handle = &address; // address of pointer cout << "index 1 : " << ***address_of_handle; 

but apart getting familiar pointers wonder why wanna this?


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -