Anda di halaman 1dari 2

UNIVERSIDAD NACIONAL DE TRUJILLO

ESCUELA DE INGENIERA DE SISTEMAS

LABORATORIO N 03
MTODOS RECURSIVOS PARA OPERAR MATRICES ESTTICAS
OPERACIONES A IMPLEMENTAR

a) Creacin del espacio de memoria para la matriz.


b) Generacin aleatoria de nmeros enteros menores a 100 y carga de datos en la Matriz.
c) Imprimir los elementos de la matriz..

// ConsolaAppMatrices.cpp: define el punto de entrada de la aplicacin de consola.


#include "stdafx.h"
#include "random"
#include "iostream"
using namespace std;

class OPERACIONES
{
public:
int matriz[3][4]; // Matriz de 3 filas y 4 columnas
int f; // objeto para procesar filas de la matriz
int c; // objeto para procesar columnas de la matriz
public:
void CargarMatriz(int[][4], int, int);
void ImprimeMatriz(int[][4], int, int);
};

void OPERACIONES::CargarMatriz(int M[][4], int xf, int xc)


{
if(xf<3)
{
if(xc<4)
{
M[xf][xc]=rand()%100;
CargarMatriz(M, xf, xc+1);
}
else
CargarMatriz(M, xf+1, 0);
}
}

void OPERACIONES::ImprimeMatriz(int M[][4], int xf, int xc)


{
if(xf<3)
{
if(xc<4)
{
if(M[xf][xc]<10)
cout<<"0"<<M[xf][xc];
else
cout<<M[xf][xc];
if(xc==3)
cout<<" ";

DR. LUIS BOY CHAVIL 1


UNIVERSIDAD NACIONAL DE TRUJILLO
ESCUELA DE INGENIERA DE SISTEMAS

else
cout<<" - ";
ImprimeMatriz(M, xf, xc+1);
}
else
{
cout<<endl;
ImprimeMatriz(M, xf+1, 0);
}
}
}

int _tmain(int argc, _TCHAR* argv[])


{
OPERACIONES OP;
OP.CargarMatriz(OP.matriz, 0, 0);
OP.ImprimeMatriz(OP.matriz, 0, 0);
system("PAUSE");
return 0;
}

DR. LUIS BOY CHAVIL 2

Anda mungkin juga menyukai