-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_hospital.cpp
More file actions
76 lines (50 loc) · 1.56 KB
/
main_hospital.cpp
File metadata and controls
76 lines (50 loc) · 1.56 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include <iostream>
#include "cprio.h"
#include <list> // PODRIAMOS USAR NUESTRA IMPLEMENTACION DE LISTAS (USO ESTA PARA EVITAR TENER QUE MANDAR MAS ARCHIVOS DISTINTOS)
struct Paciente {
string nombre;
int gravedad;
bool operator > (Paciente &otro){
return gravedad < otro.gravedad;
}
bool operator < (Paciente &otro){
return gravedad > otro.gravedad;
}
};
int main (int argc, char * const argv[]){
TCPrio<Paciente> consultas(63);
list<string> atendidos;
cout << "Introduce el numero de eventos y que eventos son: " << endl;
int numevent;
cin >> numevent;
while (numevent > 0){
char evento;
cin >> evento;
if (evento == 'I'){
string nombrePaciente;
int gravedadPaciente;
cin >> nombrePaciente >> gravedadPaciente;
Paciente p;
p.nombre = nombrePaciente;
p.gravedad = gravedadPaciente; //lo pongo en negativo para no tener que hacer el cambio a maximo y poder usar minimo
consultas.anyade(p);
}
if (evento == 'A'){
atendidos.push_back(consultas.min().nombre);
consultas.quitaMin();
}
numevent --;
}
int cero;
cin >> cero;
cout << endl;
for (string nombre: atendidos){
cout << nombre << endl;
}
cout << "---" << endl;
return 0;
}
/*
Puesto que tenemos que es un bucle respecto el numero de eventos y que todas las operaciones interiores son de coste constante menos quitarMIn() que es logaritmico respecto al numero de eventos (pues es AVL)
Así el coste del programa sera O(nlogn) siendo n = nº de eventos
*/