Ver Mensaje Individual
  #2 (permalink)  
Antiguo 21/10/2009, 10:40
Avatar de fradve
fradve
 
Fecha de Ingreso: abril-2009
Mensajes: 157
Antigüedad: 15 años, 11 meses
Puntos: 7
Respuesta: Manejar array bidimensional con punteros

Para un array dinámico bidimencional pudes hacer esto:

Código c++:
Ver original
  1. void main()
  2. {
  3.   float matriz;
  4.  
  5.   matriz=new float*[6];
  6.   //tambien puedes usar
  7.   //(float**)malloc(5*sizeof(float*));
  8.   ingresar(matriz,4,5); //no necesariamente usas todas las posiciones de memoria
  9.   presentar(matriz,4,5);
  10.  
  11. }
  12.  
  13.  
  14. void ingresar(float **p,int nf,int nc)
  15. {
  16.   int i=0,j=0;
  17.  
  18.   for(i=0;i<nf;i++)
  19.   {
  20.     for(j=0;j<nc;j++)
  21.        cin >> p[i][j];
  22.   }
  23. }
  24.  
  25. void presentar(float **p,int nf,int nc)
  26. {
  27.   int i=0,j=0;
  28.  
  29.   for(i=0;i<nf;i++)
  30.   {
  31.     for(j=0;j<nc;j++)
  32.        cout << p[i][j];
  33.   }
  34. }
__________________
En programación hay mil y un formas de hacer lo mismo...