-
Notifications
You must be signed in to change notification settings - Fork 0
/
ajudaC.c
55 lines (50 loc) · 1.59 KB
/
ajudaC.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <ctype.h>
void triagePatient(char *name, int age, char *infectiousDiseaseSuspected) {
// Convert the infectious disease suspected input to uppercase
for (int i = 0; i < strlen(infectiousDiseaseSuspected); i++) {
infectiousDiseaseSuspected[i] = toupper(infectiousDiseaseSuspected[i]);
}
// Determine which room the patient should be sent to
char *room;
if (strcmp(infectiousDiseaseSuspected, "YES") == 0) {
room = "YELLOW";
} else if (strcmp(infectiousDiseaseSuspected, "NO") == 0) {
room = "WHITE";
} else {
printf("Please respond to the infectious disease suspected question with YES or NO\n");
return;
}
printf("Send the patient to the %s room\n", room);
// Determine if the patient has priority
bool priority = false;
if (age >= 65) {
priority = true;
} else {
printf("Enter the patient's gender: ");
char gender[10];
scanf("%s", gender);
for (int i = 0; i < strlen(gender); i++) {
gender[i] = toupper(gender[i]);
}
if (strcmp(gender, "FEMALE") == 0 && age > 10) {
printf("Is the patient pregnant? ");
char pregnancy[10];
scanf("%s", pregnancy);
for (int i = 0; i < strlen(pregnancy); i++) {
pregnancy[i] = toupper(pregnancy[i]);
}
if (strcmp(pregnancy, "YES") == 0) {
priority = true;
}
}
}
printf("Patient %s priority\n", priority ? "has" : "does NOT have");
}
int main(void) {
// Example usage
triagePatient("John", 30, "yes");
return 0;
}