


























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



























#include<iostream.h> #include<conio.h> #include<graphics.h> #include<dos.h> #include<ctype.h> #include<stdlib.h> #include<stdio.h> int *v[15]; class visual { private: int h; int k; public: visual() { h=0; k=0; } image(); make(int x,int y); adf(int q); adl(int q); put(int ,int);
putt(int,int); puttt(int,int); df(); dl(int a); search(int k); ccurr(int x,int y,int z); }; // NODE CLASS class node { private: int info; //object+next node *next; public: setinfo(int x); int getinfo(); setnext(node *n); node *getnext(); }; node::setinfo(int x) { info=x; }
find (); Delete(); int display(); int displayl(); sdisplay(); visual *v; }; linklist::addinfo(int info) { setcolor(1); sprintf(buffer,"%d",info); outtextxy(31,165,buffer); getch(); node *nnode =new node; nnode->setinfo(info); nnode->setnext(NULL); if(head==NULL) { head=nnode; tail=nnode; } else {
nnode->setnext(head); head=nnode; } } linklist::Add() { int j,k=0; char c,*buffer; do { node *nnode=new node; int n,j; cleardevice(); setfillstyle(11,8); floodfill(1,1,1); setcolor(5); settextstyle(10,0,4); outtextxy(130,1,"ADDING NODE"); setcolor(1); settextstyle(1,0,2); outtextxy(120,100,"Enter F For First _____________[F]"); setcolor(2); settextstyle(1,0,2); outtextxy(120,130,"Enter L For Last_______________[L]"); setcolor(3); settextstyle(1,0,2);
if(head==NULL) { head=nnode; tail=nnode; } else { nnode->setnext(head); head=nnode; } break; case 'l': cleardevice(); setcolor(1); settextstyle(1,0,1); outtextxy(20,20,"Adding Node at Last"); j=displayl(); v->make(470,150); outtextxy(90,70,"Enter Value "); gotoxy(30,6); cin>>n; setcolor(1); sprintf(buffer,"%d",n); outtextxy(477,155,buffer);//change getch();
v->adl(n); getch(); nnode ->setinfo(n); nnode ->setnext(NULL); { tail->setnext(nnode); tail=nnode; } break; case 'c': cleardevice(); settextstyle(1,0,1); outtextxy(15,1,"Enter value after which you want to add "); gotoxy(55,1); cin>>n; int x,f=-1; curent=head; j=0; while(curent!=NULL) { if(curent->getinfo()==n) { f=1; break; }
else if(curent==head) { nnode->setnext(curent->getnext()); head->setnext(nnode); p=1; } else { nnode->setnext(curent->getnext()); curent->setnext(nnode); p=1; } v->ccurr(j+80,40,p); getch(); } else { cleardevice(); gotoxy(15,15); cout<<"NOT FOUND"; getch(); } break; }
while(c!=27); } linklist::Delete() { if(head==NULL) { cleardevice(); setfillstyle(11,8); floodfill(1,1,1); for(int a=0;a<15;a++) { setcolor(a); settextstyle(10,0,5); outtextxy(150,150,"NOT FOUND"); delay(100); } } else { char c; do {
v->search(2); v->df(); getch(); if(curr!=NULL) { head = head->getnext(); delete curr; } cleardevice(); setcolor(1); displayl(); gotoxy(13,5); cout<<" NODE DELETED.....!"; getch(); break; case 'l': j=2; cleardevice(); displayl(); if(head==NULL) { setfillstyle(11,8); floodfill(1,1,1); for(int a=0;a<15;a++)
setcolor(a); settextstyle(10,0,3); outtextxy(150,150,"THERE IS NO LIST"); delay(100); } } else { while(curr->getnext()!=tail) { curr=curr->getnext(); j=j+124; } v->search(j+124); v->dl(j+124); getch(); delete tail; settextstyle(10,0,3); outtextxy(150,150,"NODE DELETED....!"); getch(); tail=curr ; tail->setnext(NULL); cleardevice(); displayl();
v->dl(j); head=head->getnext(); delete curr; } else if(curr==tail) { v->dl(j); pre->setnext(NULL); tail=pre; //not working delete curr; } else { pre->setnext(curr->getnext()); v->dl(j);//new delete curr; } getch(); cleardevice(); displayl(); getch(); } else
cleardevice(); setfillstyle(11,8); floodfill(1,1,1); for(int a=0;a<15;a++) { setcolor(a); settextstyle(10,0,5); outtextxy(150,150,"NOT FOUND"); delay(100); } getch(); break; } } while(c!=27); } } linklist::find() { int f=-1,n,m=0,j; gotoxy(10,6); cout<<"Enter Value Which You Want To Find "; cin>>n; node *current = head;
setfillstyle(11,8); floodfill(1,1,1); for(int a=0;a<15;a++) { setcolor(a); settextstyle(10,0,5); outtextxy(150,150,"NOT FOUND"); delay(100); } } getch(); } int x=485,y=150,z,h; int linklist::display() { setcolor(1); x=485; node *current = head; while(current!=NULL) { z=485; v->put(x,y); current=current->getnext();
x=x-124; } v->putt(y,z); current=head;h=x; while(current!=NULL) { h=h+124; settextstyle(1,0,1); sprintf(buffer,"%d",current->getinfo()); outtextxy(h+5,157,buffer); current=current->getnext(); } return x; } linklist::sdisplay() { setcolor(5); settextstyle(10,0,4); outtextxy(200,1,"LINKLIST"); setcolor(1); x=2; node *current = head; while(current!=NULL)