/*can you help me with this
this is double linked list that helps you to
sort integer value in increasing order
I hope I will get answer thank you*/
#include<iostream>
using namespace std;
struct Node
int data;
Node *next;
Node *prev;
}*head,*tail;
void main()
{
head = NULL;
int n;
Node *p, *temp;
cout << "Enter Number of Nodes ";
cin >> n;
cout << "Enter elements\n";
for (int i = 1; i <= n; i++) {
if (head == NULL) {
head = new Node;
tail = head;
cin >> head->data;
head->next = NULL;
head->prev = NULL;
}
else {
p = head;
tail = new Node;
while (p != NULL)
p = p->next;
temp = new Node;
cin >> temp->data;
p->next = temp;
temp->prev = p;
temp->next = NULL;
tail = temp;
}
}
Node *q = head;
while (q != NULL)
cout << q->data << " ";
cout << endl;
}
Habib_5 0 Newbie Poster
L7Sqr 227 Practically a Master Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.