Sat Apr 07, 2007 3:12 am
#include
#include
struct node
{
int data;
node *next;
};
class list
{
list() {head=current=tail=0;}
private:
node *head;
node *tail;
node *current;
public:
///put i at the beganning of j
//********************************copy function********************
void selectionsort(list &ok)
{
int max=0;
node *h;
for(h=head;h->next!=0;h=h->next)
if (h->data > max)
{ max=h->data;
ok.insert(max);
}
/*list *copy()
{list opop;
list opo;
if(head==0) coutnext!=0;head=head->next)
{node *noda=new node;
noda->data =h->data;
noda ->data=h->data;
if(opop.head==0)
{
opop.head->next=noda;
opop.head=opop.tail=noda;
}
else
{
opop.tail->next=noda;
opop.tail=noda;
opop.tail->next=0;
}
opop.display();
}
}
return 0;
}////////*/
//****************************************************************
list(int a[],int n)////insert the array of the size n in the list
{
head=tail=0;
for(int i=0;idata=elm;
if(head==0)
{
head=tail=n;
}
else
{
tail->next=n;
tail=n;
tail->next=0;
}
}
void display()
{
node *c=new node;
if(head==0)
{
coutnext!=0;c=c->next)
{
coutdatadatanext=head;}
void main()
{
list ok;
int size,size2;
cout>size;
int *n=new int[size];
for(int i=0;i>n[i];
}
list l(n,size);
l.display();
cout>size2;
int *u=new int[size2];
for(int p=0;p>u[p];
}
list k(u,size2);
l.append(k);
k.display();
l.selectionsort(ok);
ok.display();
}
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.