# include <stdio.h> # include <stdlib.h> #define MAX 100 typedef struct Persona { int Ide; int Edad; float Peso; float Altura; }Persona; typedef struct Alumno { Persona Datos; int AgnoIngreso; float Notas[3]; }Alumno; typedef struct Curso { Alumno Arreglo[MAX]; int NumProfesor; }Curso; void muestraCurso(Curso C,int n) { int i,j; for (i=0;i<n;i++) { printf(">>> Alumno No %d<<< \n",i+1); printf("Ide: %d\n",((C).Arreglo.Datos.Ide)); printf("Edad: %d\n",((C).Arreglo.Datos.Edad)); printf("Peso: %f\n",((C).Arreglo.Datos.Peso)); printf("Altura: %f\n",((C).Arreglo.Datos.Altura)); printf("Agno de Ingreso: %d\n",((C).Arreglo.AgnoIngreso)); for (j=0;j<3;j++) { printf("Nota %d: %f\n",j+1,((C).Arreglo.Notas[j])); } printf("\n"); } printf("NumProfesor: %d \n",((C).NumProfesor)); printf("\n"); } void llenaCurso(Curso *C,int n) { int i,j; while(n>MAX) { printf("ERROR. La cantidad de alumnos debe ser menor o igual a cien.\n"); printf("Vuelva a ingresar la cantidad: "); scanf("%d",&n); } for (i=0;i<n;i++) { printf(" Alumno No %d \n",i+1); printf("Ingrese Ide: "); scanf("%d",&((*C).Arreglo.Datos.Ide)); printf("Ingrese Edad: "); scanf("%d",&((*C).Arreglo.Datos.Edad)); printf("Ingrese Peso: "); scanf("%f",&((*C).Arreglo.Datos.Peso)); printf("Ingrese Altura: "); scanf("%f",&((*C).Arreglo.Datos.Altura)); printf("Ingrese Agno de Ingreso: "); scanf("%d",&((*C).Arreglo.AgnoIngreso)); for (j=0;j<3;j++) { printf("ingrese nota %d: ",j+1); scanf("%f",&((*C).Arreglo.Notas[j])); } printf("\n"); } printf("ingrese NumProfesor: "); scanf("%d",&((*C).NumProfesor)); printf("\n"); } int mejorCurso(Curso C,int n) { int i,j,Ide; float suma,promedio,promediomayor=0; for (i=0;i<n;i++) { suma =0; for (j=0;j<3;j++) { suma = ((C).Arreglo.Notas[j]); promedio= suma/3.0; } if(promedio > promediomayor) { promediomayor = promedio; Ide = ((C).Arreglo.Datos.Ide); } } return Ide; } void despliegaCurso(Curso C, int n) { int i; printf("Alumnos que ingresan antes del 2003 y pesan mas de 60 kilos:\n"); for (i=0;i<n;i++) if( ((C).Arreglo.AgnoIngreso)<2003 && ((C).Arreglo.Datos.Peso)>60 ) printf("- Ide: %d ; Edad: %d \n",((C).Arreglo.Datos.Ide),((C).Arreglo.Datos.Edad)); printf("\n"); } int main() { Curso C; int n, x; printf("Ingrese Cantidad de Alumnos : "); scanf("%d",&n); llenaCurso(&C,n); muestraCurso(C,n); //identificador del mejor alumno x = mejorCurso(C,n); printf("El mejor alumno es %d\n",x); /* muestra IDE y EDAD de los alumnos que ingresan antes del 2003 y pesan mas de 60 kilos */ despliegaCurso(C, n); system("pause"); }