Está en la página 1de 13

UNIVERSIDAD NACIONAL DE SAN ANTONIO ABAD DEL CUSCO

FACULTAD DE INGENIERIA ELÉCTRICA, ELECTRÓNICA,


INFORMÁTICA Y MECÁNICA
ESCUELA PROFESIONAL DE INGENIERIA INFORMATICA Y DE
SISTEMAS

TEMA: EJERCICIOS CLASES Y ARREGLO DE OBJETOS

CURSO: ALGORITMOS Y ESTRUCTURA DE DATOS

DOCENTE: PROF. ARTURO ROZAS HUACHO

ALUMNA:

PEÑA LUQUE RAISA MELINA 182927

CUSCO-PERU
2019
using System;

namespace EJERCICIOS_ALGORITMOS_Y_ESTRUCTURA_DE_DATOS
{

class Program

/*PROBLEMA 1 :En un Arreglo de objetos se tiene la relación de los alumnos

matriculados en la asignatura de Algorítmica II, En otro Arreglo de objetos se tiene la relación

de los alumnos matriculados en la asignatura de Laboratorio II.

Escribir módulos para:*/

//PARTE a) .- Mostrar la relación de alumnos que estén matriculados en ambas asignaturas.

public static void RelacionInterseccion(cArregloObjetos A, cArregloObjetos L,String Texto)

Console.WriteLine(Texto);

for(int k=0;k<A.NroObjetos;k++)

cAlumno Aux = A.GetObjeto(k) as cAlumno;

int Ubi = L.Indice(Aux);

if (Ubi != -1)

Aux.Escribir();

//Parte 2)Generar un arreglo con la relación de los alumnos que estén matriculados en Algorítmica II y no estén en
Laboratorio II.

public static cArregloObjetos ArregloDiferenciaDeAlumnos(cArreglObjetos A, cArregloObjetos L)

cArregloObjetos Aux = new cArregloObjetos(A.NroObjetos);

for (int k=0; k<A.NroObjetos;k++ )

int Ubi = L.Indice(A.GetObjeto(k));

if (Ubi == -1)

Aux.Agregar(A.GetObjeto(k));

return Aux;

/*EJERCICIO 2:Se tiene implementado la clase CDeportista con los siguientes atributos: aIdDeportista, aNombres,
aFechaNacimiento, aGenero, aDisciplina. También se tiene dos Arreglo de objetos, en el primero se tiene almacenados
objetos de la clase CDeportista correspondientes a la selección de Ingeniería Informática y de Sistemas; en el segundo, a los
correspondientes a la selección de la UNSAAC.

Escribir módulos a nivel de usuario para determinar:*/

//parte 1)En cuál de las selecciones hay más deportistas del sexo femenino.

public static string MasDeportistas(cArregoObjeto SI, cArregloObjeto SU, string Genero)

int CantSI = 0;

for (int k = 0; k < SI.NroObjetos; k++)

cDeportista Aux = SI.GetObjeto(k) as cDeportista;

if ((Aux.Genero.Equals(Genero))

CantSI += 1;

int CantSU = 0;

for (int k = 0; k < SU.NroObjetos; k++)

cDeportista Aux = SU.GetObjeto(k) as cDeportista;

if ((Aux.Genero.Equals(Genero))

CantSU += 1;

if (CantSI > CantSU)

string Cadena = "Ingenieria Informatica y de Sistemas";

return Cadena;

else

string Cadena = "UNSAAC";

return Cadena;

/*parte 2)El monto total requerido para que los integrantes sólo de la disciplina de Fútbol de ambas selecciones viajen a
la ciudad de Lima para competir en las olimpiadas universitarias,

considerando que para cada integrante se requiere S/. X. (que incluye: Pasajes, alojamiento y viáticos).*/

public static int ContarDisciplina(cArregloObjetos A,string Disciplina)


{

int Cant = 0;

for (int k = 0; k < A.NroObjetos; k++)

if ((A.GetObjeto(k) as cDeportista).Disciplina.Equals(Disciplina))

Cant++;

return Cant;

public static float MontoTotal(cArregloObjetos SI,cArregloObjetos SU,float x,string Disciplina)

float Total = x * ContarDisciplina(SI, Disciplina) + x * ContarDisciplina(SU, Disciplina);

return Total;

/*PROBLEMA 3:Se tiene implementado la clase CInvestigador con los siguientes atributos: aIdInvestigador, aNombres,
aGenero, aLineaInvestigacion, aCondicion. También se tiene en dos

Arreglo de objetos a los equipos de estudiantes investigadores de las Escuelas profesionales de Ciencias de la
Computación e

Ingeniería de Software. Escribir módulos para:*/

//PARTE 1:Determinar en cuál de los equipos hay más investigadores del sexo femenino.

public static int ContarGenero(cArregloObjetos A, string Genero)

int Cant = 0;

for (int k = 0; k < A.NroObjetos; k++)

if ((A.GetObjeto(k) as cInvestigador).Genero.Equals(Genero))

Cant++;

return Cant;

public static string MasInvestigadores(cArregloObjetos CC, cArregloObjetos IS,string Genero)

if (ContarGenero(CC, Genero) > ContarGenero(IS, Genero))

string Nombre = "Ciencias de la computacion";

return Nombre;
}

else

if(ContarGenero(CC,Genero)==ContarGenero(IS,Genero))

string Nombre = "Hay la misma cantidad de investigadores del sexo femenino en ambos grupos:Ciencias de la
Computacion e Ingenieria de Software";

return Nombre;

else

string Nombre = "Ingenieria de Software";

return Nombre;

//parte 2):Generar un Arreglo de objetos con los investigadores de condición igual a “Responsable” de ambas Escuelas
profesionales.

public static cArregloObjetos GenerarArreglo(cArregloObjetos CC,cArregloObjetos IS)

cArregloObjetos Aux = new cArregloObjetos(CC.NroObjetos+IS.NroObjetos);

AgregarArreglo(Aux, CC, "Responsable");

AgregarArreglo(Aux, CC, "Responsable");

public static void AgregarArreglo(cArregloObjetos AResult,cArregloObjetos A,string Condicion)

for(int k=0;k<A.NroObjetos;k++)

if ((A.GetObjeto(k) as cInvestigador).Condicion.Equals(Condicion))

AResult.Agregar(A.GetObjeto(k));

/*PROBLEMA 4:Se tiene implementado la clase CDeportista con los siguientes atributos:
aIdDeportista, aNombres, aFechaNacimiento, aGenero. También se tiene tres arreglos,

en el primero se tiene almacenados objetos de la clase CDeportista correspondientes a la disciplina

de Fútbol, en el segundo a los correspondientes a la disciplina de Voley-ball y en el último a los de la disciplina de


Basket-ball.

Escribir módulos a nivel de usuario para determinar:*/

//parte 1:.- En cuántas disciplinas participa un deportista dado.

public static int ContadorDeDisciplinasPart(cArregloObjetos F,cArregloObjetos V, cArregloObjetos B, object Deportista)

int Cant = 0;

if (F.Indice(Deportista) != -1)

Cant++;

if (V.Indice(Deportista) != -1)

Cant++;

if (B.Indice(Deportista) != -1)

Cant++;

return Cant;

//parte 2:.- En qué disciplina participan más mujeres.

public static int Contar(cArregloObjetos A,string Genero)

int Cant = 0;

for(int k=0;k<A.NroObjetos;k++)

if ((A.GetObjeo(k) as cDeportista).Genero.Equals(Genero))

Cant++;

return Cant;

public static int Mayor(int A,int B)

if (A > B)

return A;

else

return B;

}
public static string DisciplinaMasParticipada(cArregloObjetos F,cArregloObjetos V,cArregloObjetos B, string Genero)

int CantF = Contar(F, Genero);

int CantV = Contar(V, Genero);

int CantB = Contar(B, Genero);

int Aux = Mayor(CantF,CantV);

int Mayor1 = Mayor(Aux, CantB));

if (Mayor1 == CantF && Mayor1 == CantV && Mayor1 == CantB)

return "En las 3 disciplinas participa la misma cantidad de mujeres";

else

if (Mayor1 == CantF && Mayor1 == CantV)

return "Participan mas mujeres en las disciplinas de Futbol y Voley";

else

if (Mayor1 == CantF && Mayor1 == CantB)

return "Participan mas mujeres en las disciplinas de Futbol y Basket";

else

if (Mayor1 == CantV && Mayor1 == CantB)

return "Participan mas mujeres en las disciplinas de Voley y Basket";

else

if (Mayor1 == CantF)

return "Futbol";

else

if (Mayor1 == CantB)

return "Basket";

else

return "Voley";
}

//Parte 3):Cuántos deportistas que practican Fútbol también practican Basket-ball.

public static int InterseccionDeportistas(cArregloObjetos F, cArregloObjetos B)

int Cant = 0;

for(int k=0;k<F.NroObjetos;k++)

if (B.Indice(F.GetObjeto(k)) != -1)

Cant++;

return Cant;

/*PROBLEMA 5:En la universidad se tienen diferentes centros de investigación, cada

En este contexto, en un Arreglo de objetos se tiene objetos de la clase CCentroInvestigacion con los atributos:

Codigo, Nombre, Responsable, Docentes, Estudiantes, Trabajos.

El atributo Docentes es un Arreglo de objetos que contiene objetos de la clase CDocente, el atributo Estudiantes
también es un Arreglo de objetos que contiene objetos de la clase CAlumno, finalmente, el atributo Trabajos también es un
Arreglo de objetos que contiene objetos de la clase CTrabajoInvestigacion.

La clase CTrabajoInvestigacion tiene los siguientes atributos: IdTrabajo, Titulo, Area, Presupuesto.*/

// PARTE 1:Determinar el centro de investigación que más trabajos ha realizado.

public static string CentroConMasTrabajos(cArregloObjetos A)

int Mayor = (A.GetObjeto(0) as cCentroInvestigacion).GetTrabajos.NroObjetos;

string CentInv = (A.GetObjeto(0) as cCentroInvestigacion).Nombre;

for (int k=1;k<A.NroObjetos)

if((A.GetObjeto(k) as cCentroInvestigacion).GetTrabajos.NroObjetos >Mayor)

Mayor = (A.GetObjeto(k) as cCentroInvestigacion).GetTrabajos.NroObjetos;

CentInv= (A.GetObjeto(k) as cCentroInvestigacion).Nombre;


}

return CentInv;

//PARTE 2):Generar una lista con los trabajos de investigación cuyo presupuesto sea mayor a S/. 10000.

public static void AgregarArregloTrabInv(cArregloObjetos A, string Condicion)

cArregloObjetos Trabajos = new cArregloObjetos();

for (int k = 0; k < A.NroObjetos; k++)

cArregloObjetos Aux = (A.GetObjeto(k) as cCentroInvestigacion).GetTrabajos;

for (int i=0;i<Aux.NroObjetos;i++)

if ((Aux.GetObjeto(i) as cTrabajoInvestigacion).Presupuesto > 10000)

Trabajos.Agregar(Aux.GetObjeto(i));

//PARTE 3):Determinar la relación de centros de investigación que tengan más estudiantes que docentes.

public static void RelacionCentrosInv(cArregloObjetos A)

Console.WriteLine("Relacion de Centros de Investigacion que tienen mas estudiantes que docentes");

Console.WriteLine("============================================================================");

for(int k=0;k<A.NroObjetos;k++)

cArregloObjetos Est = (A.GetObjeto(k) as cCentroInvestigacion).GetEstudiantes;

cArregloObjetos Doc = (A.GetObjeto(k) as cCentroInvestigacion).GetDocentes;

if(Est.NroObjetos>Doc.NroObjetos)

(A.GetObjeto(k) as cCentroInvestigacion).Escribir();

}
}

//PARTE 4):Determinar la relación de centros de investigación que tengan algún trabajo de investigación del área de
“Tecnologías de la información”.

public static void CentrosDeInvConUnTrabajoDet(cArregloObjetos A)

Console.WriteLine("Relacion de Centros de Investigacion que tienen algun trabajo de");

Console.WriteLine("investigacion del area de Tecnologias de la informacion");

Console.WriteLine("==================================================================");

for (int k=0;k<A.NroObjetos;k++)

cArregloObjetos Aux = (A.GetObjeto(k) as cCentroInvestigacion).GetTrabajos;

int Cant = 0;

for(int i=0;i<Aux.NroObjetos)

if ((Aux.GetObjeto(i) as cTrabjoInvestigacion).Area.Equals("Tecnologias de la informacion"))

Cant++;

if(Cant>0)

(A.GetObjeto(k) as cCentroInvestigacion).Escribir();

//PARTE 5:Determinar en cuántos trabajos de investigación participa un docente de un código dado.

/*PROBLEMA 6:En un Arreglo de objetos se tiene objetos de la clase CLibro. La clase CLibro tiene los siguientes atributos:

Codigo, Titulo, Autor, Editorial, Especialidad y Anio. Escribir módulos para:*/

//PARTE1: Determinar el número de libros que corresponden a un determinado año.

public static int NroLibrosAnio(cArregloObjetos L,string Anio)

int Cant = 0;
for (int k = 0; k < L.NroObjetos; k++)

if ((L.GetObjeto(k) as cLibro).Anio.Equals(Anio))

Cant++;

return Cant;

//PARTE 2:Determinar el número de libros escritos por un determinado autor.

public static int NroLibrosAutor(cArregloObjetos L, string Autor)

int Cant = 0;

for (int k = 0; k < L.NroObjetos; k++)

if ((L.GetObjeto(k) as cLibro).Autor.Equals(Autor))

Cant++;

return Cant;

//PARTE 3:.- Determinar en qué año: 2015 ó 2016 se tienen más libros de la especialidad de “Algorítmica”.

public static string AnioMasLibrosEspecialidad(cArregloObjetos A)

int Cant15 = 0;

int Cant16 = 0;

for (int k = 0; k < A.NroObjetos; k++)

if((A.GetObjeto(k) as cLibro).Anio==2015 && (A.GetObjeto(k) as cLibro).Especialidad=="Algoríitmica")

Cant15++;

if ((A.GetObjeto(k) as cLibro).Anio == 2016 && (A.GetObjeto(k) as cLibro).Especialidad == "Algoríitmica")

Cant16++;

if (Cant15 > Cant16)


return "2015";

else

return "2016";

También podría gustarte