diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..1da0ecb Binary files /dev/null and b/.DS_Store differ diff --git a/Examen1/Data_Statistic.csv b/Examen1/Data_Statistic.csv new file mode 100644 index 0000000..a23b550 --- /dev/null +++ b/Examen1/Data_Statistic.csv @@ -0,0 +1,6 @@ +Media: + 4 +Mediana: + 4 +Moda: + 5 diff --git a/Examen1/Data_histo.csv b/Examen1/Data_histo.csv new file mode 100644 index 0000000..8b4f2c1 --- /dev/null +++ b/Examen1/Data_histo.csv @@ -0,0 +1,50 @@ +5, 27 +5, 26 +5, 25 +4, 23 +4, 22 +4, 21 +5, 24 +5, 23 +4, 20 +5, 22 +5, 21 +4, 19 +5, 20 +4, 18 +5, 19 +5, 18 +5, 17 +5, 16 +5, 15 +5, 14 +4, 17 +4, 16 +5, 13 +4, 15 +4, 14 +5, 12 +4, 13 +4, 12 +5, 11 +5, 10 +5, 9 +4, 11 +5, 8 +4, 10 +5, 7 +4, 9 +5, 6 +4, 8 +4, 7 +4, 6 +4, 5 +4, 4 +5, 5 +5, 4 +4, 3 +4, 2 +5, 3 +5, 2 +5, 1 +4, 1 diff --git a/Examen1/Examen 1 David Perez .pdf b/Examen1/Examen 1 David Perez .pdf new file mode 100644 index 0000000..e61e7e7 Binary files /dev/null and b/Examen1/Examen 1 David Perez .pdf differ diff --git "a/Examen1/Primer examen parcial Grupo B Oto\303\261o 2020.pdf" "b/Examen1/Primer examen parcial Grupo B Oto\303\261o 2020.pdf" index bdc8c9b..ae9e790 100644 Binary files "a/Examen1/Primer examen parcial Grupo B Oto\303\261o 2020.pdf" and "b/Examen1/Primer examen parcial Grupo B Oto\303\261o 2020.pdf" differ diff --git a/Examen1/TDA_Statistics.c b/Examen1/TDA_Statistics.c new file mode 100644 index 0000000..e821a1a --- /dev/null +++ b/Examen1/TDA_Statistics.c @@ -0,0 +1,65 @@ +#include +#include +//#include "dispersion.h" +#include "media.h" +#include "files.h" + +int crearhnum(int aux[100][2], int num[]); +int main(void) +{ +char ar[50]; +int num[100]; +int hnum[100][2]; +int cant; +int auxcant; +int media, mediana, moda; +//int dispersion +printf("Inserte el nombre del archivo a leer: "); +scanf("%s", ar); + +files_leer(ar, num, &cant); +media=media_media(num, cant); +mediana=media_mediana(num,cant); +moda=media_moda(num,cant); + +auxcant=crearhnum(hnum, num,cant); + +files_meterdata(media, mediana, moda); + +files_meterhisto(hnum, auxcant); + +return 0; +} + +int crearhnum(int aux[100][2], int num[], int cant) +{ +int i; +int auxcant=0; +int j=0; +int moda=0, nummoda=0; +for(i=0;i +#include +#include "files.h" + +void files_leer(char name[], int num[], int *cant) +{ +FILE *archivo=NULL; +char linea[50]; + +int i=0,aux; +archivo=fopen(name, "rt"); + +while(!feof(archivo)) +{ +fgets(linea, 50, archivo); +sscanf(linea, "%d,%d",&aux, &num[i]); +if(feof(archivo)) +break; +i++; + +} +(*cant)=i; +fclose(archivo); +} + + +void files_meterhisto(int num[100][2], int cant) +{ + FILE *archivo; +int i; +archivo=fopen("Data_histo.csv", "wt"); +for(i=0;i +#include +/* + * Application specific headers required by the following declarations + * (the implementation will import its specific dependencies): + */ + +/* Constants declarations. */ + +/* Set EXTERN macro: */ + +#ifndef files_IMPORT +#define EXTERN +#else +#define EXTERN extern +#endif + +/* Types declarations. */ + +/* Global variables declarations. */ + + +/* Function prototypes. */ + + +/* + * + * La funcion files_leer lee el archivo dado por el usuario + * + * @params + * name (char[]): + * nombre del archivo a leer + * num(int[]); + * arreglo de numeros a leer + * cant (int*): + * cantidad leida de datos + * @returns + * void +*/ + + +EXTERN void files_leer(char name[], int num[], int *cant); +/* + * + * La funcion files_meterdata metes los datos calculados a un archivo; + * + * @params + * + * media(int); + * media calculada + * mediana (int); + * mediana calculada + * moda(int); + * moda calculada + * @returns + * void. +*/ + + +EXTERN void files_meterdata(int media, int mediana, int moda); + +/* + * + * La funcion files_meterhisto crear el archivo que GNUPLOT puede leer + * + * @params + * num[int **] + * arreglo doble para ver numeros + * cant (int); + * cantidad de numeros + * @returns + * void +*/ + + +EXTERN void files_meterhisto(int num[100][2], int cant); + +#undef files_IMPORT +#undef EXTERN +#endif /* files_h */ diff --git a/Examen1/media.c b/Examen1/media.c new file mode 100644 index 0000000..a7a722b --- /dev/null +++ b/Examen1/media.c @@ -0,0 +1,113 @@ +// +// media.h +// +// +// Created by David Perez on 08/10/2020. +// + + +#include +#include +#include "media.h" + +/* + * + * La funcion media_media calcula la media de los datos + * + * @params + * num (int[]): + * arreglo de numeros del archivo + * cant(int); + * cantidad de datos del array + * @returns + * int +*/ + + +int media_media(int num[], int cant) +{ + int i, sum=0; +for(i=0;i=nummoda) +{ +nummoda=aux[j][1]; +moda=aux[j][0]; +} +} + +return moda; +} diff --git a/Examen1/media.h b/Examen1/media.h new file mode 100644 index 0000000..19cfe47 --- /dev/null +++ b/Examen1/media.h @@ -0,0 +1,92 @@ +// +// media.h +// +// +// Created by David Perez on 28/09/2020. +// + +#ifndef media_h +#define media_h + + +/* + * System headers required by the following declarations + * (the implementation will import its specific dependencies): + */ + +#include +#include +/* + * Application specific headers required by the following declarations + * (the implementation will import its specific dependencies): + */ + +/* Constants declarations. */ +/* Set EXTERN macro: */ + +#ifndef media_IMPORT +#define EXTERN +#else +#define EXTERN extern +#endif + +/* Types declarations. */ + +/* Global variables declarations. */ + + +/* Function prototypes. */ + + +/* + * + * La funcion media_media calcula la media de los datos + * + * @params + * num (int[]): + * arreglo de numeros del archivo + * cant(int); + * cantidad de datos del array + * @returns + * int +*/ + + +EXTERN int media_media(int mun[], int cant); +/* + * + * La funcion media_mediana encuenta la mediana de los datos + * del archivo. + * + * @params + * + * num(int []); + * arreglo de numeros del archivo + * cant(int); + * cantidad de elementos + * @returns + * int. +*/ + + +EXTERN int media_mediana(int num[], int cant); + +/* + * + * La funcion media_moda regresa el valor que mas veces se repitio. + * + * @params + * num(int[]); + * arreglos de numeros + * num(int); + * cantidad de elementos. + * @returns + * double +*/ + + +EXTERN int media_moda(int num[], int cant); + +#undef media_IMPORT +#undef EXTERN +#endif /* media_h */