Last active
November 29, 2017 16:16
-
-
Save kalimalrazif/437b921af96b99e9242acd5bf9677479 to your computer and use it in GitHub Desktop.
Solucion tercera prueba corta
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 "colas.h" // Aca esta la implementacion de colas que es general para todo lo que use cola | |
struct nodo { | |
int turno; | |
struct nodo *sig; | |
} | |
struct cola { | |
struct nodo *punta; | |
struct nodo *fin; | |
int cont; | |
} | |
int main(){ | |
struct cola viejos; | |
struct cola jovenes; | |
/* como habiamos quedado segun el enunciado las colas estan magicamente llenas de la gente que ya pidio su turno */ | |
int orden = 0; | |
while(1){ | |
int turno; | |
int result; | |
if (orden < 3 ) { | |
result = pop(&viejos,&turno); | |
} else { | |
result = pop(&jovenes,&turno); | |
} | |
if (result == 1) { // si el resultado no es 1 es decir cola vacia u otro mensaje de error, obvia la parte de imprimir, e intenta de nuevo hasta que consiga un numero. | |
printf("Siguiente en atender: %03d", turno); | |
} | |
orden++; | |
if (orden > 4 ) { orden = 0; } | |
getc(); // no importa realmente si es enter o cualquier otra tecla | |
} | |
return 1; // nunca llega aca, pero para efectos del examen no importa :-) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment