加急!!!求救!!c语言,链表的操作!知道
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351...全部
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312#define N 20typedef struct LNode{ char num[N]; char name[N]; int age; float Score; LNode *next;}LNode;class LinkList{private: LNode *head; int length;public: LinkList(); bool IsCreate(); void ListSize(); void CreatList(); void InsertList(); void DeleteList(); void Find(); void Display(); void BubbleSortList(); void Count();};-------------------#include "ds。
h"#include #include string。h>#include stdlib。h>#include conio。h>using namespace std; LinkList::LinkList(){ head=(LNode *)malloc(sizeof(LNode)); head->next=NULL; length=0;}bool LinkList::IsCreate(){ if(length==0) return 0; return 1;}void LinkList::ListSize(){ if(!IsCreate()) { cout>n; LNode *p=head;length=n; for(int i=n;i>0;i--) { LNode *p=(LNode *)malloc(sizeof(LNode)); cout>p->num; cout>p->name; cout>p->age; cout>p->Score; coutnext=head->next; head->next=p; } cout>num; LNode *p=head->next; while(p&&strcmp(p->num,num)!=0) { p=p->next; } if(!p)cout>num; LNode *p=head; while(p->next&&strcmp(p->next->num,num)!=0) { p=p->next; } if(!(p->next))coutnext; p->next=p->next->next; free(q); } coutnext; while(p) { coutnext; } cout>n; if(nlength 1)coutnext; i ; } cout>q->num; cout>q->name; cout>q->age; cout>q->Score; q->next=p->next; p->next=q; length ; coutnext; LNode *_node=head->next; char temp1[N],temp2[N];int temp3;float temp4; for(;_temp->next;_temp=_temp->next) { for(_node=head->next;_node->next;_node=_node->next) { if(_node->Scorenext->Score) { strcpy(temp1,_node->num); strcpy(_node->num,_node->next->num); strcpy(_node->next->num,temp1); strcpy(temp2,_node->name); strcpy(_node->name,_node->next->name); strcpy(_node->next->name,temp2); temp3=_node->age; _node->age=_node->next->age; _node->next->age=temp3; temp4=_node->Score; _node->Score=_node->next->Score; _node->next->Score=temp4; } } } }}void LinkList::Count(){ if(!IsCreate()) { coutnext;int count=0; while(p) { if(p->Scorenext; } cout>order; switch(order) { case 1: L。
CreatList();break; case 2: L。Display();;break; case 3: L。InsertList();break; case 4: L。
DeleteList();;break; case 5: L。Find();break; case 6: L。ListSize();break; case 7: L。
BubbleSortList();break; case 8: L。Count();break; case 9: flag=0;break; } cout>a; if(!strcmp(a,"Y")||!strcmp(a,"y")) { coutvc6可以运行ds。
h就是前半部分#include 改成:#include using namespace std;加外, 在而且工具==〉编译环境==〉目录==〉包含文件 -->C 中要有这一句:C:Dev-Cpp_gcc321Dev-Cppincludec mingw32C:Dev-Cpp_gcc321Dev-Cpp是我的DEV安装目录根据你的安装目录做适当修改:。
收起