![Antiguo](http://static.forosdelweb.com/fdwtheme/images/statusicon/post_old.gif)
26/03/2003, 07:29
|
![Avatar de ferny](http://static.forosdelweb.com/customavatars/avatar16893_2.gif) | Il capo della mafia | | Fecha de Ingreso: febrero-2002 Ubicación: Al final del cable
Mensajes: 10.080
Antigüedad: 23 años Puntos: 55 | |
Liberar memoria (C++) Este es el programa:
Código:
#include <iostream.h>
int main(int argc, char *argv[])
{
int m=3;
int n=2;
typedef double* Fila;
typedef Fila* Matriz;
Matriz a;
a = new Fila[n]; // n FILAS
int i,j;
for ( i = 0 ; i < n ; i++ )
{
a[i] = new double[m]; // m COLUMNAS
} //Final del for
for ( i = 0 ; i < n ; i++)
{
for ( j = 0 ; j < m ; j++)
{
cout << "A[" << i + 1 << "," << j + 1 << "] = ";
cin >> a[i][j];
cout << "\n";
}
}
for ( i = 0 ; i < n ; i++)
{
for ( j = 0 ; j < m ; j++)
{
cout << a[i][j] << " ";
}
cout << "\n";
}
if( a[0][0] != 0 )
{
// Divido la fila primera por su primer elemento
for (j=0; j<m; j++)
{
a[0][j] = a[0][j] / a[0][0];
}
/* La segunda fila es la segunda fila - la primera fila + el primer
elemento de la segunda fila*/
for (j=0; j<m; j++)
{
a[1][j] = a[1][j] - a[0][j]*a[1][0];
}
}
cin >> a[0][0];
// Eliminar las fugas de memoria
ESTO ES LO QUE NECESITO
return 0;
}
¿Cómo libero la memoria?
Un saludo
__________________ www.mundodivx.com || www.mundodivx.org Pon tu mano en un horno caliente durante un minuto y te parecerá una hora.
Siéntate junto a una chica preciosa durante una hora y te parecerá un minuto.
Eso es la relatividad. |