Last active
August 29, 2015 14:03
-
-
Save GusGA/204867ca47b5515e194f to your computer and use it in GitHub Desktop.
Ejercicios del trabajo de recuperación de Prog I - IUGT
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // main.c | |
| // ejercicio_uno_dos | |
| // | |
| // Created by Gustavo Gimenez on 7/8/14. | |
| // Copyright (c) 2014 Gustavo Gimenez. All rights reserved. | |
| // | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <time.h> | |
| /* | |
| Para generar la nota de mamera automatica y aleatoria se utilizará la funcion rand() | |
| */ | |
| int notas_parciales_curso_c[3][30]; // Matriz de parciales del curso de C (filas => parciales / columnas => alumnos) | |
| float promedio_de_alumnos[30]; // Una posicion por nota del alumno. | |
| //Funciones | |
| void nota_para_parciales(); // Función que generará la nota para cada parcial | |
| void mostrar_notas(); | |
| void promedio_por_alumno(); | |
| void promedio_por_parcial(); | |
| void prom_mayor(); | |
| void p_general(); | |
| int main(int argc, const char * argv[]) | |
| { | |
| //Función srand que genera la cuenta inicial para la generación aleatoria | |
| srand (time(NULL)); | |
| nota_para_parciales(); | |
| mostrar_notas(); | |
| printf("\n"); | |
| promedio_por_alumno(); | |
| printf("\n"); | |
| p_general(); | |
| printf("\n"); | |
| prom_mayor(); | |
| printf("\n"); | |
| promedio_por_parcial(); | |
| printf("\n"); | |
| return 0; | |
| } | |
| void nota_para_parciales(){ | |
| for (int i = 0; i < 3; i++){ | |
| for(int j = 0; j < 30; j++){ | |
| notas_parciales_curso_c[i][j] = rand() % 20 + 1; // valores aleatorios del 1 al 20 | |
| } | |
| } | |
| } | |
| void mostrar_notas(){ | |
| for (int i = 0; i < 3; i++){ | |
| printf("Nota parcial %d\n",i+1); | |
| for(int j = 0; j < 30; j++){ | |
| printf(" %d",notas_parciales_curso_c[i][j]); | |
| } | |
| printf("\n"); | |
| } | |
| } | |
| void promedio_por_alumno(){ | |
| float temp = 0.0; | |
| float promedio = 0.0; | |
| int aplazados_por_promedio = 0; | |
| printf("Las notas promedio de cada alumno son:\n"); | |
| for (int j = 0; j < 30; j ++) { | |
| for (int i = 0; i < 3; i++) { | |
| temp += notas_parciales_curso_c[i][j]; | |
| } | |
| promedio = temp / 3; | |
| promedio_de_alumnos[j] = promedio; | |
| if( promedio < 10 ) { | |
| aplazados_por_promedio += 1; | |
| } | |
| temp = 0.0; | |
| promedio = 0.0; | |
| printf("%.2f ", promedio_de_alumnos[j]); | |
| } | |
| printf("\n"); | |
| printf("La cantidad de aplazos por en el curso de C son %d\n", aplazados_por_promedio); | |
| } | |
| void prom_mayor(){ | |
| float promedio_mayor = 0.0; | |
| int indice = 0; | |
| for (int j = 0; j < 30; j++) { | |
| if (promedio_mayor < promedio_de_alumnos[j]) { | |
| promedio_mayor = promedio_de_alumnos[j]; | |
| indice = j; | |
| } | |
| } | |
| printf("El mayor promedio es del alumno %d y su nota es %.2f\n",indice, promedio_mayor); | |
| } | |
| void promedio_por_parcial(){ | |
| int sum = 0; | |
| int acum = 0; | |
| int aplazados[3]; | |
| float promedio_parciales[3]; | |
| for (int i = 0; i < 3; i++) { | |
| for (int j = 0; j < 30; j++) { | |
| sum += notas_parciales_curso_c[i][j]; | |
| if (notas_parciales_curso_c[i][j] < 10){ | |
| acum += 1; | |
| } | |
| } | |
| promedio_parciales[i] = sum / 30; | |
| aplazados[i] = acum; | |
| sum = 0; | |
| acum = 0; | |
| } | |
| printf("Los promedio por parciales son:\n"); | |
| for(int x = 0; x < 3; x++){ | |
| printf("Parcial %d => %.2f\n",x+1,promedio_parciales[x]); | |
| } | |
| printf("Los aplazados por parciales son: \n"); | |
| for(int x = 0; x < 3; x++){ | |
| printf("Parcial %d => %d\n",x+1,aplazados[x]); | |
| } | |
| } | |
| void p_general(){ | |
| float acum = 0.0; | |
| for (int j = 0 ; j < 30; j++) { | |
| acum += promedio_de_alumnos[j]; | |
| } | |
| printf("El promedio general del curso es %.2f\n", acum / 30); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // main.c | |
| // trabajo_uno_uno | |
| // | |
| // Created by Gustavo Gimenez on 7/8/14. | |
| // Copyright (c) 2014 Gustavo Gimenez. All rights reserved. | |
| // | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <time.h> | |
| /* | |
| Para la elección de la reina cada alumno votará por su candidata preferida de la siguiente manera: | |
| Para llenar de forma automatica y de manera aleatoria los votos, se utilizará la función rand() | |
| */ | |
| int turno_manana[6][6]; //Cada turno esta compuesto por 6 carreras y 6 candidatas por carrera | |
| int turno_noche[6][6]; | |
| int resultados[6][6]; | |
| int candidatas_ganadoras[6]; | |
| int acum_por_candidata[6]; | |
| /* | |
| Cargador de votos aleatorios | |
| para el programa los votos estaran en la escala de 20 a 40 puntos por candidata | |
| */ | |
| void votos_aleatorios(); | |
| void mostrar_votos_manana(); | |
| void mostrar_votos_noche(); | |
| //Declaración de las funciones del programa | |
| void ganadoras_por_carrera(); | |
| void ganadoras_nocturno(); | |
| void ganadoras_iugt(); | |
| int main() | |
| { | |
| srand(time(0)); | |
| votos_aleatorios(); | |
| mostrar_votos_manana(); | |
| printf("\n"); | |
| mostrar_votos_noche(); | |
| printf("\n"); | |
| ganadoras_por_carrera(); | |
| printf("\n"); | |
| ganadoras_iugt(); | |
| printf("\n"); | |
| return 0; | |
| } | |
| void votos_aleatorios(){ | |
| int i; | |
| int j; | |
| for (i = 0; i < 6; i++) { | |
| for (j = 0; j < 6; j++) { | |
| turno_manana[i][j] = rand() % 20 + 20; | |
| turno_noche[i][j] = rand() % 20 + 20; | |
| resultados[i][j] = (int) turno_manana[i][j] + turno_noche[i][j]; | |
| } | |
| } | |
| } | |
| void mostrar_votos_manana(){ | |
| int i; | |
| int j; | |
| printf("Votos de las candidatas turno diurno\n"); | |
| printf("--------------------------------------\n"); | |
| for ( i = 0; i < 6; i++) { | |
| printf("Carrera %d ->\t", i + 1); | |
| for (j = 0; j < 6; j++) { | |
| printf("%d\t\t",turno_manana[i][j]); | |
| } | |
| printf("\n"); | |
| } | |
| } | |
| void mostrar_votos_noche(){ | |
| int i; | |
| int j; | |
| printf("Votos de las candidatas turno nocturno\n"); | |
| printf("--------------------------------------\n"); | |
| for ( i = 0; i < 6; i++) { | |
| printf("Carrera %d ->\t", i + 1); | |
| for (j = 0; j < 6; j++) { | |
| printf("%d\t\t",turno_noche[i][j]); | |
| } | |
| printf("\n"); | |
| }// end for | |
| } | |
| void ganadoras_por_carrera(){ | |
| int temp[2]; | |
| int i; | |
| int j; | |
| float acum_por_carrera[6]; | |
| printf("Ganadoras por carrera\n"); | |
| printf("-------------------------------------\n"); | |
| for (i = 0 ; i < 6; i++) { | |
| for (j = 0; j < 6; j++) { | |
| acum_por_candidata[j] += resultados[i][j]; | |
| acum_por_carrera[i] += resultados[i][j]; | |
| if (temp[0] <= 0){ | |
| temp[0] = turno_noche[i][j]; | |
| temp[1] = j; | |
| } else if (temp[0] < turno_noche[i][j]){ | |
| temp[0] = turno_noche[i][j]; | |
| temp[1]= j; | |
| } | |
| }//Fin columnas | |
| printf("Carrera %d -> Candidata %d con %d votos\n", i + 1 , temp[1] + 1, temp[0]); | |
| temp[0] = 0; | |
| temp[1] = 0; | |
| }//Fin Filas | |
| printf("\n"); | |
| printf("El Promedio de votos por:\n"); | |
| for(i = 0; i< 6 ; i++){ | |
| printf("Carrera %d ->\t",i + 1); | |
| printf("%.2f\t\t", (float) acum_por_carrera[i] / 6.0); | |
| printf("Candidata %d ->\t", i +1); | |
| printf("%.2f\n", (float) acum_por_candidata[i] / 6.0 ); | |
| } | |
| } | |
| void ganadoras_iugt(){ | |
| int i; | |
| int temp[2]; | |
| int temp_carr[2] ; | |
| for (i = 0; i < 6; i++) { | |
| if (temp[0] < acum_por_candidata[i]){ | |
| temp[0] = acum_por_candidata[i]; | |
| temp[1] = i; | |
| } | |
| } | |
| printf("La Ganadora es la Candidata %d con %d votos\n", temp[1] + 1, temp[0]); | |
| for (i = 0; i < 6; i++) { | |
| if (temp_carr[0] < resultados[i][temp[1]]) | |
| temp_carr[0] = resultados[i][temp[1]]; | |
| temp_carr[1] = i; | |
| } | |
| printf("La ganadora obtuvo más votos en la carrera %d con %d\n", temp_carr[1] + 1, temp_carr[0]); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment