#include <iostream>
class CObject
{
public:
virtual int CompareTo(CObject& object)=0;
bool operator>(CObject& object);
};
bool CObject::operator >(CObject& object)
{
return CompareTo(object)>0;
}
class CNode
{
friend class LinkedList;
private:
CNode * m_prev;
CNode * m_next;
CObject * m_object;
char Name[10];
char No[10];
public:
CNode(CObject * object=NULL)
{
m_object = object;
m_prev = NULL;
m_next = NULL;
}
};
class LinkedList
{
private:
CNode * m_head;
CNode * m_rear;
int m_size;
public:
LinkedList()
{
m_size = 0;
m_head = new CNode();
m_rear = new CNode();
m_head->m_prev = NULL;
m_head->m_next = m_rear;
m_rear->m_prev = m_head;
m_rear->m_next = NULL;
char Name[10];
char No[10];
}
void Add_head(char name[],char no[])
{
Node(name,no);
rear->next=from->next;
front=&node;
size++;
}
void Add_rear(char name[],char no[])
{
Node(name,no);
rear->next=&node;
rear=&node;
size++;
}
void delete_head()
{
if(size==0)
{ cout<<"链表空"<<endl;
exit(1);
}
head=head->next;
size--;
}
void find(int index)
{ Node *m_head;
m_head=head;
if((index<0)||(index>size))
{ cout<<"结果不存在!"<<endl;
exit(1);
}
for(int i=1;i<index-1;i++)
m_head=m_head->next;
cout<<"你要查找的姓名是:"<<m_head->Name<<endl<<"学号是:"<<m_head->No<<endl;
}
void bublle(int a[],int n) //冒泡排序
{ int i,j,t,temp;
for(i=1;i<=n-1;i++)
{ t=n-1;
for(j=0;j<t-1;j++)
{ if (a[j]>a[j+1])
{ temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
}
};
void main()
{}