искам да направя скрипт на ц++ , който да ми трансформира квадратна матрица от н-ти ред във вектор ето така :

1 2 3
4 5 6 = 1 4 7 2 5 8 3 6 9 .....
7 8 9

#include <iostream.h>
#include <math.h>
#include <iomanip.h>

template < typename T >
T **Allocate2DArray( int nRows, int nCols )
{
//(step 1) allocate memory for array of elements of column
T **ppi = new T* (nRows);

//(step 2) allocate memory for array of elements of each row
T *curPtr = new T (nRows * nCols);

// Now point the pointers in the right place
for( int i = 0; i < nRows; i++)
{
*(ppi + i) = curPtr;
curPtr = +nCols;
}
return ppi;
}



void methodCOL(int matrix&#91;]&#91;], int matrixOrder);
{
// new vector[order*order, 1];
int** vector = Allocate2DArray< int >((matrixOrder * matrixOrder), 1);


int vectorCnt = 0;
for (int col=0; col<matrixOrder; ++col)
{
for (int row=0; row<matrixOrder; ++row)
{
vector[vectorCnt, 0] = matrix[row][col];
vectorCnt++;
}
cout << endl;
}
}

int main()
{
double **d = Allocate2DArray< double >(10000, 10000);
d[0][0] = 10.0;
d[1][1] = 20.0;
d[9999][9999] = 2345.09;
Free2DArray(d);
system("PAUSE");
return 0;

}

a = 1;
b = a++; // a= 2; b = 1;
b = ++a; // a = 2; b = 2;