Created
June 11, 2022 03:02
-
-
Save arnaldog/d5fd31377ec11653aac39c172d7b5bcf to your computer and use it in GitHub Desktop.
programa nachin
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
#include <stdio.h> | |
#include <stdlib.h> | |
float porcentaje_covid(float casos_positivos, float casos_totales) { | |
return casos_positivos * 100 / casos_totales; | |
} | |
int menor_comparacion(float temperatura, float menor_temperatura) { | |
if (temperatura <= menor_temperatura) { | |
return 2; | |
} | |
return 1; | |
} | |
int mayor_comparacion(float temperatura, float mayor_temperatura) { | |
if (temperatura >= mayor_temperatura) { | |
return 2; | |
} | |
return 1; | |
} | |
void rango_temperatura(int mayor_rut, int menor_rut, int menor_edad, int mayor_edad, float ma_temp, float me_temp, | |
char mayor_sexo, char menor_sexo) { | |
printf("\nLa persona con menor temperatura fue : >Rut: %d, >Sexo : %c ,>Edad : %d, registrando una temperatura de: %f ", | |
menor_rut, menor_sexo, menor_edad, me_temp); | |
printf("\nLa persona con mayor temperatura fue : >Rut: %d, >Sexo : %c ,>Edad : %d, registrando una temperatura de: %f ", | |
mayor_rut, mayor_sexo, mayor_edad, ma_temp); | |
printf("\nLos rangos de temperatura fueron: %f - %f", me_temp, ma_temp); | |
} | |
int main() { | |
int rut, edad, diagnostico, mas_total, fem_total, covid_total, | |
pacientes_totales, menor_rut, mayor_rut; | |
int menor_edad, mayor_edad; | |
char sexo, mayor_sexo, menor_sexo; | |
float temperatura, menor_temperatura , mayor_temperatura; | |
edad = 0, diagnostico = 0, mas_total = 0, fem_total = 0, | |
covid_total = 0, pacientes_totales = 0; | |
menor_rut = 0, mayor_rut = 0, menor_edad = 0, mayor_edad = 0; | |
temperatura = 0, menor_temperatura = 0, mayor_temperatura = 0; | |
float ma_temp = 0, me_temp = 0; | |
printf("=====BIENVENIDO AL COMPILADOR ESTADISTICO=====\n"); | |
printf("\nIngresar datos de los pacientes:"); | |
while (rut != 0) { | |
printf("\nIngrese su rut( al digitar 0 el programa termina mostrando los datos): "); | |
scanf("%d", &rut); | |
if (rut == 0) { | |
break; | |
} | |
pacientes_totales++; | |
printf("\nIngrese sexo: masculino (m) o femenino(f).\n"); | |
scanf("%s", &sexo); | |
printf("\nIngrese Edad.\n"); | |
scanf("%d", &edad); | |
printf("\nIngrese Diagonostico. pulse 1 Si el paciente tiene COVID19 o 2: Si es otro diagnostico\n"); | |
scanf("%d", &diagnostico); | |
if (diagnostico == 1) { | |
covid_total++; | |
if (sexo == 'm') { | |
mas_total++; | |
} | |
if (edad >= 40 && sexo == 'f') { | |
fem_total++; | |
} | |
} | |
printf("\nIngrese temperatura en grados Celcius (C).\n"); | |
scanf("%f", &temperatura); | |
if (menor_temperatura == 0) { | |
menor_temperatura = temperatura; | |
} | |
if (menor_comparacion(temperatura, menor_temperatura) == 2) { | |
menor_rut = rut; | |
menor_edad = edad; | |
menor_sexo = sexo; | |
menor_temperatura = temperatura; | |
} | |
if (mayor_temperatura == 0) { | |
mayor_temperatura = temperatura; | |
} | |
if (mayor_comparacion(temperatura, mayor_temperatura) == 2) { | |
mayor_rut = rut; | |
mayor_edad = edad; | |
mayor_sexo = sexo; | |
mayor_temperatura = temperatura; | |
} | |
} | |
printf("\nPacientes de sexo Masculino diagnosticados con COVID19 son:%d", mas_total); | |
printf("\nPacientes de Sexo Femenino mayores de 40 años con COVID19 son:%d", fem_total); | |
printf("\nPorcentaje de pacientes detectado por COVID19: %f", | |
porcentaje_covid(covid_total, pacientes_totales)); | |
printf("\nPaciente con menor temperatura"); | |
printf("\n\tRut: %d", menor_rut); | |
printf("\n\tEdad: %d", menor_edad); | |
printf("\n\tSexo: %c", menor_sexo); | |
printf("\n"); | |
printf("\nPaciente con mayor temperatura: Rut: %d", mayor_rut); | |
printf("\nPaciente con mayor temperatura: Edad: %d", mayor_edad); | |
printf("\nPaciente con mayor temperatura: Sexo %c", mayor_sexo); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment