#include using namespace std; class Date { public: Date():date(1){} Date(int number):date(number){} virtual ~Date(){}; int GetDate()const{return date;} virtual void print()const =0; private: int date; }; class Book:public Date { public: Book():Price(94){} Book(float Price,int number); virtual void print()const { cout<<"图书编号为:"<getDate(); else return NULL; } Date*List::operator[](int offset)const { Node*pn=head; if(!head) return NULL; if(offset>count) return NULL; for(int i=0;igetnext(); return pn->getDate(); } Date*List::find(int number)const { Node*pn=0; for(pn=head;pn!=NULL;pn=pn->getnext()) { if(pn->getDate()->GetDate()==number) break; } if(pn==NULL) return NULL; else return pn->getDate(); } Date*List::find(int &increase,int number)const { Node*pn=0; for(pn=head,increase=0;pn!=NULL;pn=pn->getnext(),increase++) { if(pn->getDate()->GetDate()==number) break; } if(pn==NULL) return NULL; else return pn->getDate(); } void List::repeat()const { if(!head) return; Node*pn=head; do pn->getDate()->print(); while(pn=pn->getnext()); } void List::insert(Date*pDate) { Node*pn=new Node(pDate); Node*pNow=head; Node*pNext=0; int New=pDate->GetDate(); int next=0; count++; if(!head) { head=pn; return; } if(head->getDate()->GetDate()>New) { pn->setnext(head); head=pn; return; } for(;;) { if(!pNow->getnext()) { pNow->setnext(pn); return; } pNext=pNow->getnext(); next=pNext->getDate()->GetDate(); if(next>New) { pNow->setnext(pn); pn->setnext(pNext); return; } pNow=pNext; } } class Repair { public: void insert(Date*); void PrintAll(){ll.repeat();} private: Node*head; List ll; }; void Repair::insert(Date*newdate) { int num=newdate->GetDate(); int place=0; if(!ll.find(place,num)) ll.insert(newdate); else { cout<<"您输入的编号"<>choice; if(!choice) break; cout<<"请输入编号:"; cin>>number; if(choice==1) { cout<<"请输入图书价格:"; cin>>value; pDate=new Book(value,number); } else { cout<<"请输入药品价格:"; cin>>value; pDate=new medica(value,number); } pl.insert(pDate); } pl.PrintAll(); return 0; }