Untitled
unknown
plain_text
a year ago
3.7 kB
0
Indexable
Never
int main() { Queue fast,normal; Element element; char comando; char basura; int cantidadfast = 0,cantidadnormal = 0; fast = QUEUE_create(); normal = QUEUE_create(); /* F -> Fast N -> Normal A -> Enter attraction Q -> Quit */ do { scanf("%c",&comando); //Solo roba hasta el ' ' o el '\n' scanf("%c",&basura); //Roba el espacio o el salto de linea switch(comando) { case 'F': scanf("%d",&element.size); scanf("%c",&basura); scanf("%s",element.name); scanf("%c",&basura); cantidadfast = cantidadfast + element.size; if(cantidadfast > QUEUE_SIZE) { printf("The Fast queue is full.\n"); } else { QUEUE_add(&fast,element); printf("%s (%d) has been added to the Fast queue.\n",element.name,element.size); } // QUEUE_add(&fast,element); // if(QUEUE_NO_ERROR == QUEUE_getErrorCode(fast)) { // printf("%s (%d) has been added to the Fast queue.\n",element.name,element.size); // } else { // if(QUEUE_ERROR_FULL == QUEUE_getErrorCode(fast)) { // printf("The Fast queue is full.\n"); // } // } break; case 'N': scanf("%d",&element.size); scanf("%c",&basura); scanf("%s",element.name); scanf("%c",&basura); cantidadnormal = cantidadnormal + element.size; if(cantidadnormal > QUEUE_SIZE) { printf("The Fast queue is full.\n"); } else { QUEUE_add(&normal,element); printf("%s (%d) has been added to the Normal queue.\n",element.name,element.size); } // QUEUE_add(&fast,element); // if(QUEUE_NO_ERROR == QUEUE_getErrorCode(normal)) { // printf("%s (%d) has been added to the Normal queue.\n",element.name,element.size); // } else { // if(QUEUE_ERROR_FULL == QUEUE_getErrorCode(normal)) { // printf("The Normal queue is full.\n"); // } // } break; case 'A': if(QUEUE_isEmpty(fast) && QUEUE_isEmpty(normal)) { printf("No group is available yet.\n"); } else { if(!QUEUE_isEmpty(fast)) { element = QUEUE_getFirst(&fast); cantidadfast = cantidadfast - element.size; printf("%s (%d) has entered the attraction.\n",element.name,element.size); QUEUE_remove(&fast); } else { if(!QUEUE_isEmpty(normal)) { element = QUEUE_getFirst(&normal); cantidadnormal = cantidadnormal - element.size; printf("%s (%d) has entered the attraction.\n",element.name,element.size); QUEUE_remove(&normal); } } } break; case 'Q': QUEUE_destroy(&fast); QUEUE_destroy(&normal); printf("See you soon!\n"); break; } }while(comando != 'Q'); return 0; }