拿去做下参考,你该下就行了。#include#include#include#include//用getch();usingnamespacestd;//﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌Student类﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌classStudent{public:charname[20];charId[20];intCnum;//C课程得分intMnum;//数学课程得分intEnum;//英语课程得分intsum;//总分Student*Next;voidInput(){cout>name;cout>Id;cout>Cnum;cout>Mnum;cout>Enum;sum=Cnum+Mnum+Enum;}voidReadFile(istream&in){in>>name>>Id>>Cnum>>Mnum>>Enum>>sum;}voidShow(){coutNext;p!=End;p=p->Next)p->Show();coutInput();End->Next=newStudent;End=End->Next;coutNext!=End;p=p->Next)//匹配成功则返回上一个指针,不成功就返回空if(!strcmp(p->Next->name,name))returnp;returnNULL;}Student*FindID(char*Id){for(Student*p=Head;p->Next!=End;p=p->Next)//匹配成功则返回上一个指针,不成功就返回空if(!strcmp(p->Next->Id,Id))returnp;returnNULL;}};//﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌构造函数﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌Studentmassage::Studentmassage(){Head=newStudent;Head->Next=newStudent;End=Head->Next;in.open("sort.txt");if(!in)coutReadFile(in);if(End->name[0]=='\0')break;End->Next=newStudent;End=End->Next;}in.close();coutNext!=End;){temp=Head->Next;Head->Next=Head->Next->Next;deletetemp;}deleteHead,End;}//﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌菜单﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌voidStudentmassage::ShowMenu(){cout>x;switch(x){case1:{cout>name;if(p=FindItem(name)){p->Next->Show();cout>Id;if(p=FindID(Id)){p->Next->Show();cout>name;if(p=FindItem(name)){coutNext->Input();cout>name;if(p=FindItem(name)){temp=p->Next;p->Next=p->Next->Next;deletetemp;coutname,p1->name);strcpy(temp->Id,p1->Id);temp->Cnum=p1->Cnum;temp->Mnum=p1->Mnum;temp->Enum=p1->Enum;temp->sum=p1->sum;strcpy(p1->name,p2->name);strcpy(p1->Id,p2->Id);p1->Cnum=p2->Cnum;p1->Mnum=p2->Mnum;p1->Enum=p2->Enum;p1->sum=p2->sum;strcpy(p2->name,temp->name);strcpy(p2->Id,temp->Id);p2->Cnum=temp->Cnum;p2->Mnum=temp->Mnum;p2->Enum=temp->Enum;p2->sum=temp->sum;}//﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌intStudentmassage::ListCount()//统计当前链表的记录总数,返回一个整数{if(!Head)return0;intn=0;for(Student*p=Head->Next;p!=End;p=p->Next){n++;}returnn;}//﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌voidStudentmassage::Sort()//对当前链表进行排序{coutNext;p!=End;p=p->Next)for(k=p->Next;k!=End;k=k->Next){if(p->sum>k->sum){Studentmassage::Swap(p,k);}}coutNext;p!=End;p=p->Next)out>x;switch(x){case0:quit=true;break;case1:Grade.AddItem();break;case2:Grade.Display();break;case3:Grade.Sort();break;case4:Grade.Find();break;case5:Grade.RemoveItem();break;case6:Grade.ModifyItem();break;}}return0;}