Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- typedef struct node{
- int data;
- struct node *next;
- struct node *pre;
- }node;
- typedef struct {
- node *head;
- node *tail;
- }Queue;
- void intiallize (Queue *q){
- q->head = q->tail = NULL;
- }
- int isempty(Queue *q){
- return q->head==NULL;
- }
- void add_in_front(Queue *q, int x){
- node *p = (node*) malloc(sizeof(node));
- if (!isempty(q)){
- p->data = x;
- p->next = q->head;
- p->pre = NULL;
- (q->tail)->next=p;
- }else{
- p->data = x;
- p->next = NULL;
- p->pre = NULL;
- (q->tail)->next=p;
- }
- }
- int main()
- {
- Queue q; intiallize(&q);
- printf("Hello world!\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement