C++ 风格
double** allocateHeap(int rows, int cols)
{
double **A;
A = new double* [rows];
for (int i=0; i<rows; i++)
{
A[i] = new double [cols];
}
return A;
}
void releaseHeap(double** A, int rows)
{
for (int i=0; i<rows; i++)
{
delete[] A[i];
}
delete[] A;
}
C 风格
double **p;
int i;
p = (double **)malloc(20 * sizeof(double *))
for(i = 0; i < 20; i++)
{
p[i] = (double *)malloc(30 * sizeof(double))
}
for(i = 0; i < 20; i++)
{
free(p[i]);
}
free(p);