You've already forked Curso-lenguaje-C
Update PR3
This commit is contained in:
BIN
fundamentos-programacion/PR3/soluciones_c/solucion2/max
Executable file
BIN
fundamentos-programacion/PR3/soluciones_c/solucion2/max
Executable file
Binary file not shown.
30
fundamentos-programacion/PR3/soluciones_c/solucion2/max.c
Normal file
30
fundamentos-programacion/PR3/soluciones_c/solucion2/max.c
Normal file
@@ -0,0 +1,30 @@
|
||||
#include <stdio.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float collect[10];
|
||||
int position;
|
||||
} tReal;
|
||||
|
||||
void maxValores(tReal *tabla)
|
||||
{
|
||||
float max = tabla->collect[0];
|
||||
for (int i = 1; i < tabla->position; i++)
|
||||
{
|
||||
if (tabla->collect[i] > max)
|
||||
{
|
||||
max = tabla->collect[i];
|
||||
}
|
||||
}
|
||||
|
||||
printf("%f", max);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
tReal tabla = {{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0}, 10};
|
||||
|
||||
maxValores(&tabla);
|
||||
|
||||
return 0;
|
||||
}
|
||||
BIN
fundamentos-programacion/PR3/soluciones_c/solucion3/min
Executable file
BIN
fundamentos-programacion/PR3/soluciones_c/solucion3/min
Executable file
Binary file not shown.
29
fundamentos-programacion/PR3/soluciones_c/solucion3/min.c
Normal file
29
fundamentos-programacion/PR3/soluciones_c/solucion3/min.c
Normal file
@@ -0,0 +1,29 @@
|
||||
#include <stdio.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float collect[10];
|
||||
int position;
|
||||
} tReal;
|
||||
|
||||
void minValores(tReal *tabla)
|
||||
{
|
||||
float min = tabla->collect[0];
|
||||
for (int i = 1; i < tabla->position; i++)
|
||||
{
|
||||
if (tabla->collect[i] < min)
|
||||
{
|
||||
min = tabla->collect[i];
|
||||
}
|
||||
}
|
||||
printf("%f", min);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
tReal tabla = {{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0}, 10};
|
||||
|
||||
minValores(&tabla);
|
||||
|
||||
return 0;
|
||||
}
|
||||
BIN
fundamentos-programacion/PR3/soluciones_c/solucion4/suma
Executable file
BIN
fundamentos-programacion/PR3/soluciones_c/solucion4/suma
Executable file
Binary file not shown.
26
fundamentos-programacion/PR3/soluciones_c/solucion4/suma.c
Normal file
26
fundamentos-programacion/PR3/soluciones_c/solucion4/suma.c
Normal file
@@ -0,0 +1,26 @@
|
||||
#include <stdio.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float collect[10];
|
||||
int position;
|
||||
} tReal;
|
||||
|
||||
void sumaValores(tReal *tabla)
|
||||
{
|
||||
float suma = 0;
|
||||
for (int i = 0; i < tabla->position; i++)
|
||||
{
|
||||
suma += tabla->collect[i];
|
||||
}
|
||||
printf("%f", suma);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
tReal tabla = {{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0}, 10};
|
||||
|
||||
sumaValores(&tabla);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user