mirror of
https://github.com/TheAlgorithms/C
synced 2024-11-22 05:21:49 +03:00
Update queue.c (#622)
This commit is contained in:
parent
af6de4b7d4
commit
6f385ed4a4
@ -52,14 +52,14 @@ void enque(int x)
|
|||||||
{
|
{
|
||||||
if (head == NULL)
|
if (head == NULL)
|
||||||
{
|
{
|
||||||
head = (struct node *)malloc(1 * sizeof(struct node));
|
head = (struct node *)malloc(sizeof(struct node));
|
||||||
head->data = x;
|
head->data = x;
|
||||||
head->pre = NULL;
|
head->pre = NULL;
|
||||||
tail = head;
|
tail = head;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tmp = (struct node *)malloc(1 * sizeof(struct node));
|
tmp = (struct node *)malloc(sizeof(struct node));
|
||||||
tmp->data = x;
|
tmp->data = x;
|
||||||
tmp->next = tail;
|
tmp->next = tail;
|
||||||
tail = tmp;
|
tail = tmp;
|
||||||
@ -92,4 +92,4 @@ int deque()
|
|||||||
/**
|
/**
|
||||||
* Returns the size of the Queue.
|
* Returns the size of the Queue.
|
||||||
*/
|
*/
|
||||||
int size() { return count; }
|
int size() { return count; }
|
||||||
|
Loading…
Reference in New Issue
Block a user