Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<iostream>
- #include<stdlib.h>
- using namespace std;
- struct Node
- {
- int data;
- struct Node *next;
- }*node,*temp;
- struct Head
- {
- int count;
- struct Node *rear, *frnt;
- }*head;
- void creat_head()
- {
- head=(struct Head*)malloc(sizeof(struct Head));
- head->count=0;
- head->frnt=NULL;
- head->rear=NULL;
- }
- void creat_1st_node()
- {
- node=(struct Node*)malloc(sizeof(struct Node));
- scanf("%d",&node->data);
- node->next=NULL;
- head->frnt=node;
- head->rear=node;
- head->count++;
- }
- void creat_node()
- {
- node=(struct Node*)malloc(sizeof(struct Node));
- scanf("%d",&node->data);
- node->next=NULL;
- head->rear->next=node;
- head->rear=node;
- head->count++;
- }
- void delet_node()
- {
- temp=head->frnt;
- head->frnt=temp->next;
- free(temp);
- head->count--;
- }
- void display()
- {
- temp=head->frnt;
- for(int i=0; i<head->count; i++)
- {
- cout<<temp->data<<endl;
- temp=temp->next;
- }
- }
- int main()
- {
- creat_head();
- cout<<"creat 1st node"<<endl;
- creat_1st_node();
- cout<<"Add node"<<endl;
- creat_node();
- cout<<"Add node"<<endl;
- creat_node();
- cout<<"Add node"<<endl;
- creat_node();
- cout<<"first node deleted"<<endl;
- delet_node();
- cout<<"Queue display"<<endl;
- display();
- return 0;
- }
Add Comment
Please, Sign In to add comment