Mini Data Structure Project
Mini Data Structure Project
/* Roll-Number= FA18-MCS-008
Name = Bilal Saeed
*/
#include<iostream>
#include<conio.h>
#include<string>
struct node
string name;
int quantity;
int sales;
node *next;
node *pre;
};
class doubleLinklist{
private:
node *head;
node *tail;
public:
doubleLinklist()
{
head=NULL;
tail=NULL;
tmp->name=namee;
tmp->quantity=quantityy;
tmp->sales=sal;
tmp->next=NULL;
tmp->pre=NULL;
if(head==NULL)
head=tmp;
tail=tmp;
else
tail->next=tmp;
tmp->pre=tail;
tail=tmp;
tail->next=head;
head->pre=tail->pre;
}
}
void show()
node *ptr;
ptr=head;
if(head==NULL)
cout<<"Linklist is empty"<<endl;
else
while(ptr->next!=head)
cout<<"\nName ="<<ptr->name;
ptr=ptr->next;
cout<<"\nName ="<<ptr->name;
cout<<endl;
}
}
n1->name=name;
n1->quantity=quant;
n1->sales=sales;
n1->next=NULL;
n1->pre=NULL;
n1->next=head;
head->pre=n1;
head=n1;
head->pre=tail->pre;
tail->next=head;
bilal->next=NULL;
bilal->pre=NULL;
bilal->name=nameee;
bilal->quantity=quant;
bilal->sales=sales;
node *ptr;
ptr=head;
cout<<"Enter the name to next where you want to insert Item"<<endl;
char gt[200];
cin>>gt;
while(ptr->next!=head)
if(ptr->name==gt)
bilal->next=ptr->next;
ptr->next->pre=bilal;
ptr->next=bilal;
bilal->pre=ptr;
break;
else
ptr=ptr->next;
last->name=name;
last->quantity=quant;
last->sales=sales;
last->next=NULL;
last->pre=NULL;
if(head==NULL)
head=tail=last;
else
tail->next=last;
last->pre=tail;
tail=tail->next;
tail->next=head;
head->pre=tail->pre;
void trending();
};
void doubleLinklist::trending()
node *q,*p;
q=head;
p=q->next;
while(p!=head)
q=p;
else
p=p->next;
node *q;
q=head;
while(q!=NULL)
if(q->name==namee)
break;
}
else
q=q->next;
int main()
doubleLinklist n1;
int prod;
do{
char name[200];
cin>>name;
n1.addnode(name,quantity,sales);
}while(prod!=2);
int n;
while(n!=5){
cout<<"1. Which products are trending in Company?"<<endl;
cout<<"5. Exit"<<endl;
cin>>n;
switch(n)
case 1:
n1.trending();
break;
case 2:
n1.show();
break;
case 3:
char nam[200];
cin>>nam;
n1.single_stock(nam);
break;
case 4:
char name[200];
int num;
cin>>num;
switch(num)
case 1:
n1.instfirst(name,quantity,sales);
break;
case 2:
n1.instmid(name,quantity,sales);
cout<<"done";
break;
case 3:
n1.instlast(name,quantity,sales);
break; }