Ver Mensaje Individual
  #4 (permalink)  
Antiguo 28/02/2009, 17:28
Tet0
 
Fecha de Ingreso: octubre-2008
Mensajes: 50
Antigüedad: 15 años, 6 meses
Puntos: 2
Respuesta: Ayuda con la estructura de un programa!

una forma mas generica de hacerlo

Código:
#include <iostream>

#define SIZE 3

using namespace std;

void llenarMatriz(int *pArreglo)
{
	int i = 0;
	
	//en este bucle escoges como llenar tu matriz
	while(i < SIZE*SIZE)
		*pArreglo++ = i++; 
		
}

int main()
{
	int A[SIZE][SIZE],
		B[SIZE][SIZE],
		C[SIZE][SIZE],
		*pC = *C;

	llenarMatriz((int*)&A);
	llenarMatriz((int*)&B);
	
	for(int i = 0; i < SIZE; i++)
	{
		for(int j = 0; j < SIZE; j++)
			C[i][j] = A[i][j] + B[i][j];
	}
	
	for(int i = 0; i < SIZE*SIZE; ++i)
		cout << *pC++ << endl;
}