For my 2d array in C++, the 2d array needs to be flipped at a certain position. I have to write a function that flips the array Foe instance, Before:
double A[][2] = {{0,0}, {1,1}, {2,2}, {3,3}, {4,4}, {5,5}, {6,6}, {7,7}}
                                         A     B     C       D
call function invert(or flip): invert(A, 8, 3, 4);
after:
double A[][2] = { {0, 0}, {1, 1}, {2, 2},{6, 6}, {5, 5}, {4, 4}, {3, 3}, {7, 7}}
                                            D      C        B      A
Here is the attempt I have tried
- @param A is the list of locations (x,y) of the cities in the current tour.
- @param n is the number of cities in A.
- @param start is the index of the beginning of the section to be inverted.
- @param len is the length of the segment to invert(or flip).
    void invert ( double A[][2], int n, int start, int len ) {
          int(*tmp)[2] = new int[][2];
          for(int i = 0; i >= A.length; i--){
               for(int j = 0; j >= A[i].length; j--){
                    if( i > start)
                        tmp = A[i][j];
                 }
           }
               for(i = start; i < A.length; i++)
                  for(j = start; j < A[i].length; j++){
                     while (i <= end){
                        tmp = A[i][j];
                   }
                }
       }
The errors I have are
- expressions must have class type
- a value of type double cannot be assigned to an entity of type "double(*)[2]
- cannot determine which instance of overload function "end" is intended
I am fully aware that most of the errors in my code are evident to find, but I needed to start somewhere.
 
     
     
    