diff --git a/docs/code/Examenes/Examen_Grupo_2.2_Ejercicio_1.c b/docs/code/Examenes/Examen_Grupo_2.2_Ejercicio_1.c deleted file mode 100644 index 212fd05..0000000 --- a/docs/code/Examenes/Examen_Grupo_2.2_Ejercicio_1.c +++ /dev/null @@ -1,33 +0,0 @@ -// -// Created by angie on 11/12/2023. -// -#include -#define N 3 - -typedef struct empleado{ - char nombre[50]; - int edad; - float salario; -}nempleado; -nempleado adquirirEmpleado(nempleado * aEmp){ - printf("Nombre:\n"); - scanf("%s",&aEmp->nombre); - printf("Edad:\n"); - scanf("%d",&aEmp->edad); - printf("Salario:\n"); - scanf("%f",&aEmp->salario); -} - - -int main(){ - nempleado trabajadores[N]; - int joven=0; - adquirirEmpleado(&trabajadores[0]); - for(int i=1;i -void SolicitarEnteroPositivo(int *numeroPositivo) -{ - do{ - printf("Introduzca un numero entero positivo para saber el tamaño de la matriz:\n"); - scanf("%d",numeroPositivo); - }while(numeroPositivo<=0); - -} - -void imprimirTableroAjedrez(int numeroPositvo) -{ - int i; - int j; - for(j=0;j -#include -#include -#include - -#define OP1 'A' -#define OP2 'B' -#define SALIR 'C' - -#define N 5 -#define M 5 -#define INF_INTER 10 -#define SUP_INTER 100 -#define FACTOR 5 // múltiplos de 5 - -typedef int tMatriz[N][M]; - -int valoresContados(const tMatriz matriz); // prototipo de la función pedida - -void pedirPosicionyValor(int *pFila, int *pColumna, int *pValor); // prototipo del procedimiento pedido - -void gestionarMenu(); - -int alea(int ini, int fin); - -void mostrarMenu(); - -char opcionSeleccionada(); - -void modificar(tMatriz matriz); - -int numeroPedido(const char mensaje[], int inf, int sup); - -void iniciarMatriz(tMatriz matriz); - -void mostrarCalculo(const tMatriz matriz); - -void mostrar(const tMatriz matriz); - -char mayuscula(char caracter); - - -int main() { - srand(time(NULL)); - gestionarMenu(); - return 0; -} - -void gestionarMenu() { - bool seguir = true; - tMatriz matriz; - iniciarMatriz(matriz); - do { - mostrarMenu(); - switch (mayuscula(opcionSeleccionada())) { - case OP1: - mostrar(matriz); - modificar(matriz); - mostrar(matriz); - break; - case OP2: - mostrarCalculo(matriz); - break; - case SALIR: - seguir = false; - puts("FIN del PROGRAMA de EVALUACION de PRACTICAS"); - puts("------------------------------------------------"); - break; - default: - printf("\tERROR: Opcion no válida (elija %c, %c, %c)", OP1, OP2, SALIR); - break; - } - } while (seguir); -} - -/* - * Definición de la función qué recibe como parámetro una matriz de enteros y dicha función retorna - * cuantos valores pares hay en la estructura recibida. - */ -int valoresContados(const tMatriz matriz) { - int contador = 0; - for (int i = 0; i < N; i++) - for (int j = 0; j < N; j++) - if (matriz[i][j] % FACTOR == 0) contador++; - return contador; -} - -/* - * Definición del procedimiento que devuelve tres parámetros enteros que indicaran la posición a modificar - * y el valor entero que contendrá. - * POSTCONDICIONES: - * el valor € (INF_INTER/10, SUP_INTER/10) - * la fila € [1, N] - * la columna € [1, N] - */ -void pedirPosicionyValor(int *pFila, int *pColumna, int *pValor) { - *pValor = numeroPedido("Nuevo valor", INF_INTER / 10 + 1, SUP_INTER / 10 - 1); - *pFila = numeroPedido("para la Fila", 1, N); - *pColumna = numeroPedido("para la Columna ", 1, N); -} - -void modificar(tMatriz matriz) { - int f, c, numero; - pedirPosicionyValor(&f, &c, &numero); // POSTCond: f y c € [1,N], número € (INF_INTER/10, SUP_INTER/10) - matriz[f - 1][c - 1] = numero; // por las postcondiciones del procedimiento ajusta la posición a modificar -} - -int alea(int ini, int fin) { - int aux = rand() % (fin - ini + 1) + ini; - return aux; -} - -char mayuscula(char caracter) { - char aux = caracter; - if (caracter <= 'z' && caracter >= 'a') aux = (char) ((int) caracter - 'a' + 'A'); - return aux; -} - -int numeroPedido(const char mensaje[], int inf, int sup) { - int dato; - do { - printf("\t%s entre [%d, %d]: ", mensaje, inf, sup); - scanf("%d", &dato); - } while (dato < inf || dato > sup); - return dato; -} - -void iniciarMatriz(tMatriz matriz) { - for (int i = 0; i < N; i++) - for (int j = 0; j < M; j++) - matriz[i][j] = FACTOR * alea(INF_INTER / FACTOR, SUP_INTER / FACTOR);// mtiplo5 € [INF_INTER,SUP_INTER] -} - -void mostrarCalculo(const tMatriz matriz) { - printf("Multiplos de 5 contenidos en la matriz: %d.\n", valoresContados(matriz)); -} - -void mostrar(const tMatriz matriz){ - puts("La matriz es: "); - for (int i = 0; i < N; i++){ - for (int j = 0; j < M; j++) - printf("%10d", matriz[i][j]); - puts(""); - } -} - -char opcionSeleccionada() { - char opcion; - printf("Seleccione una opción (%c, %c y/o %c): ", OP1, OP2, SALIR); - scanf("%c", &opcion); - while(getchar() != '\n'); - return opcion; -} - -void mostrarMenu() { - puts("\n________________________________________________"); - printf("MATRIZ DE %d x %d ELEMENTOS\n", N, M); - printf("%c) Activar Procedimiento.\n", OP1); - printf("%c) Activar Funcion\n", OP2); - printf("%c) Salir\n", SALIR); -} \ No newline at end of file diff --git a/src/Examenes/CMakeLists.txt b/src/Examenes/CMakeLists.txt index ae88bf4..ca18836 100644 --- a/src/Examenes/CMakeLists.txt +++ b/src/Examenes/CMakeLists.txt @@ -3,6 +3,6 @@ project(Boletin_4 C) set(CMAKE_C_STANDARD 99) -add_executable(Examen_Grupo_3.1 Examen_Grupo_3.1.c) -add_executable(Examen_Grupo_2.2_Ejercicio_1 Examen_Grupo_2.2_Ejercicio_1.c) -add_executable(Examen_Grupo_2.2_Ejercicio_2 Examen_Grupo_2.2_Ejercicio_2.c) \ No newline at end of file +#add_executable(Examen_Grupo_3.1 Examen_Grupo_3.1.c) +#add_executable(Examen_Grupo_2.2_Ejercicio_1 Examen_Grupo_2.2_Ejercicio_1.c) +#add_executable(Examen_Grupo_2.2_Ejercicio_2 Examen_Grupo_2.2_Ejercicio_2.c) \ No newline at end of file diff --git a/src/Examenes/Examen_Grupo_2.2_Ejercicio_1.c b/src/Examenes/Examen_Grupo_2.2_Ejercicio_1.c deleted file mode 100644 index 212fd05..0000000 --- a/src/Examenes/Examen_Grupo_2.2_Ejercicio_1.c +++ /dev/null @@ -1,33 +0,0 @@ -// -// Created by angie on 11/12/2023. -// -#include -#define N 3 - -typedef struct empleado{ - char nombre[50]; - int edad; - float salario; -}nempleado; -nempleado adquirirEmpleado(nempleado * aEmp){ - printf("Nombre:\n"); - scanf("%s",&aEmp->nombre); - printf("Edad:\n"); - scanf("%d",&aEmp->edad); - printf("Salario:\n"); - scanf("%f",&aEmp->salario); -} - - -int main(){ - nempleado trabajadores[N]; - int joven=0; - adquirirEmpleado(&trabajadores[0]); - for(int i=1;i -void SolicitarEnteroPositivo(int *numeroPositivo) -{ - do{ - printf("Introduzca un numero entero positivo para saber el tamaño de la matriz:\n"); - scanf("%d",numeroPositivo); - }while(numeroPositivo<=0); - -} - -void imprimirTableroAjedrez(int numeroPositvo) -{ - int i; - int j; - for(j=0;j -#include -#include -#include - -#define OP1 'A' -#define OP2 'B' -#define SALIR 'C' - -#define N 5 -#define M 5 -#define INF_INTER 10 -#define SUP_INTER 100 -#define FACTOR 5 // múltiplos de 5 - -typedef int tMatriz[N][M]; - -int valoresContados(const tMatriz matriz); // prototipo de la función pedida - -void pedirPosicionyValor(int *pFila, int *pColumna, int *pValor); // prototipo del procedimiento pedido - -void gestionarMenu(); - -int alea(int ini, int fin); - -void mostrarMenu(); - -char opcionSeleccionada(); - -void modificar(tMatriz matriz); - -int numeroPedido(const char mensaje[], int inf, int sup); - -void iniciarMatriz(tMatriz matriz); - -void mostrarCalculo(const tMatriz matriz); - -void mostrar(const tMatriz matriz); - -char mayuscula(char caracter); - - -int main() { - srand(time(NULL)); - gestionarMenu(); - return 0; -} - -void gestionarMenu() { - bool seguir = true; - tMatriz matriz; - iniciarMatriz(matriz); - do { - mostrarMenu(); - switch (mayuscula(opcionSeleccionada())) { - case OP1: - mostrar(matriz); - modificar(matriz); - mostrar(matriz); - break; - case OP2: - mostrarCalculo(matriz); - break; - case SALIR: - seguir = false; - puts("FIN del PROGRAMA de EVALUACION de PRACTICAS"); - puts("------------------------------------------------"); - break; - default: - printf("\tERROR: Opcion no válida (elija %c, %c, %c)", OP1, OP2, SALIR); - break; - } - } while (seguir); -} - -/* - * Definición de la función qué recibe como parámetro una matriz de enteros y dicha función retorna - * cuantos valores pares hay en la estructura recibida. - */ -int valoresContados(const tMatriz matriz) { - int contador = 0; - for (int i = 0; i < N; i++) - for (int j = 0; j < N; j++) - if (matriz[i][j] % FACTOR == 0) contador++; - return contador; -} - -/* - * Definición del procedimiento que devuelve tres parámetros enteros que indicaran la posición a modificar - * y el valor entero que contendrá. - * POSTCONDICIONES: - * el valor € (INF_INTER/10, SUP_INTER/10) - * la fila € [1, N] - * la columna € [1, N] - */ -void pedirPosicionyValor(int *pFila, int *pColumna, int *pValor) { - *pValor = numeroPedido("Nuevo valor", INF_INTER / 10 + 1, SUP_INTER / 10 - 1); - *pFila = numeroPedido("para la Fila", 1, N); - *pColumna = numeroPedido("para la Columna ", 1, N); -} - -void modificar(tMatriz matriz) { - int f, c, numero; - pedirPosicionyValor(&f, &c, &numero); // POSTCond: f y c € [1,N], número € (INF_INTER/10, SUP_INTER/10) - matriz[f - 1][c - 1] = numero; // por las postcondiciones del procedimiento ajusta la posición a modificar -} - -int alea(int ini, int fin) { - int aux = rand() % (fin - ini + 1) + ini; - return aux; -} - -char mayuscula(char caracter) { - char aux = caracter; - if (caracter <= 'z' && caracter >= 'a') aux = (char) ((int) caracter - 'a' + 'A'); - return aux; -} - -int numeroPedido(const char mensaje[], int inf, int sup) { - int dato; - do { - printf("\t%s entre [%d, %d]: ", mensaje, inf, sup); - scanf("%d", &dato); - } while (dato < inf || dato > sup); - return dato; -} - -void iniciarMatriz(tMatriz matriz) { - for (int i = 0; i < N; i++) - for (int j = 0; j < M; j++) - matriz[i][j] = FACTOR * alea(INF_INTER / FACTOR, SUP_INTER / FACTOR);// mtiplo5 € [INF_INTER,SUP_INTER] -} - -void mostrarCalculo(const tMatriz matriz) { - printf("Multiplos de 5 contenidos en la matriz: %d.\n", valoresContados(matriz)); -} - -void mostrar(const tMatriz matriz){ - puts("La matriz es: "); - for (int i = 0; i < N; i++){ - for (int j = 0; j < M; j++) - printf("%10d", matriz[i][j]); - puts(""); - } -} - -char opcionSeleccionada() { - char opcion; - printf("Seleccione una opción (%c, %c y/o %c): ", OP1, OP2, SALIR); - scanf("%c", &opcion); - while(getchar() != '\n'); - return opcion; -} - -void mostrarMenu() { - puts("\n________________________________________________"); - printf("MATRIZ DE %d x %d ELEMENTOS\n", N, M); - printf("%c) Activar Procedimiento.\n", OP1); - printf("%c) Activar Funcion\n", OP2); - printf("%c) Salir\n", SALIR); -} \ No newline at end of file