Write a function in C++ to insert a circular Queue containing
Players information (represented with the help of array of structure PLAYER).
Consider following definition of Node
struct PLAYER
{
int PID;
char Pname[20];
NODE* Next;
};
#include<iostream>
using namespace std;
struct PLAYER
{
int PID;
char Pname[20];
PLAYER* Next;
};
void insert(PLAYER p[], int front, int rear, int max)
{
if((rear=max-1 && front ==0)||(front == rear +1))
{
cout<<"Circular Queue is full";
exit(0);
}
else if(front == -1 && rear == -1)
{
front = rear = 0;
}
else if(rear = max -1 && front >0)
{
rear = 0;
}
else
rear = rear+1;
cout<<"Enter Player Id and name\n";
cin>>p[rear].PID;
gets(p[rear].Pname);
}
Comments
Leave a comment