#include "persona_queue.h" // funzioni per la gestine di una struct persona static const int maxLungStringhe = 30; void stampaPersona(persona * agenda) { cout << agenda->cognome << endl << agenda->nome << endl << agenda->indirizzo << endl << agenda->numTelefono << endl << endl; } static char * getCognome () { char tmp[maxLungStringhe]; char * cognome; cin.get(); cout << "Inserisci il cognome: "; cin.getline(tmp,maxLungStringhe); cognome = new char [strlen(tmp)+1]; strcpy(cognome,tmp); return cognome; } static char * getNome () { char tmp[maxLungStringhe]; char * nome; cout << "Inserisci il nome: "; cin.getline(tmp,maxLungStringhe); nome = new char [strlen(tmp)+1]; strcpy(nome,tmp); return nome; } static char * getIndirizzo () { char tmp[maxLungStringhe]; char * indirizzo; cout << "Inserisci il indirizzo: "; cin.getline(tmp,maxLungStringhe); indirizzo = new char [strlen(tmp)+1]; strcpy(indirizzo,tmp); return indirizzo; } static char * getNumTelefono () { char tmp[maxLungStringhe]; char * numTelefono; cout << "Inserisci il numTelefono: "; cin.getline(tmp,maxLungStringhe); numTelefono = new char [strlen(tmp)+1]; strcpy(numTelefono,tmp); return numTelefono; } persona * creaPersona() { persona * p = new persona; p->cognome = getCognome(); p->nome = getNome(); p->indirizzo = getIndirizzo(); p->numTelefono = getNumTelefono(); return p; } void eliminaPersona(persona * p) { delete [] p->cognome; delete [] p->nome; delete [] p->indirizzo; delete [] p->numTelefono; delete p; } // funzioni per la gestine di una coda di struct persona static int next(int index) { return (index+1)%dim; } void init(queue & q) { q.tail=q.head=0; } static boolean emptyp(const queue & q) { return (boolean) (q.tail==q.head); } static boolean fullp(const queue & q) { return (boolean) (next(q.tail)==q.head); } retval enqueue (persona * p,queue & q) { if (fullp(q)) return FAIL; q.elem[q.tail] = p; q.tail = next(q.tail); return OK; } retval dequeue(persona * & p,queue & q) { if (emptyp(q)) return FAIL; p = q.elem[q.head]; q.head = next(q.head); return OK; } void print (const queue & q) { int i; for (i=q.head;i