Pregled posta

Adresa bloga: https://blog.dnevnik.hr/prirodaa

Marketing

red,jednostruka

#include
using namespace std;

struct node
{
int data;
node *link;
};

//DEKLARACIJE FUNKCIJA
bool queueEmpty(node *head);
void entry(node *&head, node *&tail, int elt);
int process(node *&head,node *&tail);
void deleteQueue(node *&head,node *&tail);
int waitingNum(node *head);

int main()
{
node *head=NULL, *tail=NULL;
int elt=1;
char odabir;
do
{
system("cls");
cout<<"\n\nBANKA d.d. Glavni izbornik...I-Z-B-O-R-N-I-K"< cout<<"\n1 - Ulaz nove stranke";
cout<<"\n2 - Obrada stranke";
cout<<"\n3 - Ispis trenutnog stanja";
cout<<"\n0 - Kraj";
cout<<"\n\nUnesite Vas odabir...";
cin>>odabir;
cin.ignore(1,'\n');
switch(odabir)
{
case '1':
cout<<"Klikom na gumb preuzmite listic s brojem cekanja u redu.\n";
cin.get();
entry(head,tail,elt);
elt++;
cin.get();
break;
case '2':
if(!queueEmpty(head)) cout<<"Salter je slobodan. Molimo stranku s rednim brojem: "< else cout<<"Red je prazan, nema kandidata za nove transkacije."< cin.get();
break;
case '3':
cout<<"U redu na salteru ceka "< cin.get();
break;
case '0':
cout<<"Kraj programa.\n";
}
}
while(odabir!='0');
//DEALOKACIJA!!!
deleteQueue(head,tail);
cin.sync();
cin.get();
return 0;
}

void entry(node *&head, node *&tail, int elt)
{
node *newNode=new node;
newNode->data=elt;
newNode->link=0;
if (head==0) head=newNode;
else tail->link=newNode;
tail=newNode;
cout<<"Preuzeli ste listic s rednim brojem za cekanje na nasem jedinom, ali brzom salteru.\n";
cout<<"Vas broj cekanja u redu je..."< cout<<"Broj osoba koje cekaju ispred Vas je "< }

int process(node *&head, node *&tail)
{
int elt;
elt=head->data;
node *tmp=head;
if (head==tail) tail=0;
head=head->link;
delete tmp;
return elt;
}

bool queueEmpty(node *head)
{
return (head==NULL);
}

void deleteQueue(node *&head, node *&tail)
{
node *tmp;
while (head)
{
tmp=head;
head=head->link;
delete tmp;
}
tail=NULL;
}

int waitingNum(node *head)
{
int num=0;
while (head)
{
num++;
head=head->link;
}
return num;
}


Post je objavljen 05.06.2012. u 11:23 sati.