Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changes in code #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions Mobile Telephone Service/Queuelist.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ void CreateQueue(QueueType *q)
q->front= NULL;
q->rear = NULL;
}
int QueueEmpty(QueueType q)
int QueueEmpty(QueueType *q)
{
//Pre: The queue is initialized.
//Post: If the queue is empty (1) is returned. Otherwise (0) is returned.

return (q->front == NULL);
}
int QueueFull(QueueType q)
int QueueFull(QueueType *q)
{
//Pre: The queue is initialized.
//post: If the queue is full (1) is returned. Otherwise (0) is returned.
Expand All @@ -25,9 +25,10 @@ void Enqueue(QueueEntry item, QueueType *q)
{
//Pre: The queue is initialized and is not full.
//Post: Item is added to the end of the stack.
Node *p = (Node *)malloc(sizeof(Node));
if(p->Entry[q->rear]->l.c='E')
{
Node *p = (Node *)malloc(sizeof(Node));

p->Entry[q->rear]=item;
p-> next = NULL;
if (!q->rear)
Expand All @@ -42,7 +43,7 @@ void Enqueue(QueueEntry item, QueueType *q)
}
if(p->Entry[q->rear]->l.c='V')
{
Node *p = (Node *)malloc(sizeof(Node));

p->Entry[q->rear]=item;
p-> next = NULL;
if (!q->rear)
Expand All @@ -56,10 +57,10 @@ void Enqueue(QueueEntry item, QueueType *q)

}
}
if(p->Entry[q->rear]->l.c='D') {}
Node *p = (Node *)malloc(sizeof(Node));
if(p->Entry[q->rear]->l.c='D') {

p->Entry[q->rear]=item;
p-> next = NULL;
p-> next = NULL;}
if (!q->rear)
q->front = p;
else
Expand All @@ -71,7 +72,7 @@ void dequeue (QueueEntry *item, QueueType *q)
//Pre: The Queue is initialized and is not empty.
//Post: The front element of the Queue is removed from it and is assigned to item.

*item = q->front->entry[q->front];
*item = q->front->Entry[q->front];
Node *p = q->front;
q-> front=q->front->next;
free(p);
Expand Down
2 changes: 1 addition & 1 deletion Mobile Telephone Service/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ int main()
QueueType q;
printM();
scanf("%d",&x);
do
switch(x)
{
case 1:
if(!QueueFull(q))
Expand Down