Documente Academic
Documente Profesional
Documente Cultură
{
public:
int Value;
Node *Next;
Node()
{
Value=0;
Next=NULL;
}
};
1 of 1
#include <iostream>
#include "Node.h"
class LinkedList
{
private:
Node *Head;
public:
LinkedList()
{
Head = NULL;
}
bool empty()
{
return (Head==NULL);
}
void display()
{
Node *c=Head;
cout << "\n{";
while (c)
{
cout << c->Value << ", ";
c = c->Next;
}
cout << "}\n";
}
int first()
{
if (Head!=NULL)
return Head->Value;
else
return -1;
}
void remove(int item)
{
Node *p,*d;
p=d=Head;
while (d->Next)
{
if (d->Value == item) break;
p = d;
d = d->Next;
}
1 of 2
if (d != NULL)
{
if (d==Head)
Head = d->Next;
else
p->Next = d->Next;
delete d;
}
}
};
2 of 2
#include <cstdlib>
#include <iostream>
#include "linkedlist.h"
void QuickSort(LinkedList*);
list.display();
QuickSort(&list);
list.display();
system("PAUSE");
return EXIT_SUCCESS;
}
1 of 1