当前位置: 代码迷 >> C语言 >> 剩下一个错误不知道怎么改,求高人
  详细解决方案

剩下一个错误不知道怎么改,求高人

热度:360   发布时间:2004-11-22 22:07:00.0
剩下一个错误不知道怎么改,求高人

Status InitList_CL (LinkList *L) { *L=(LinkList)malloc(sizeof(struct LNode)); if(!*L) exit(OVERFLOW); (*L)->next=*L; return OK; }

Status DestroyList_CL(LinkList *L) { LinkList q,p=(*L)->next; while(p!=*L) { q=p->next; free(p); p=q; } free(*L); *L=NULL; return OK; }

Status ClearList_CL(LinkList *L) { LinkList p,q; *L=(*L)->next; p=(*L)->next; while(p!=*L) { q=p->next; free(p); p=q; } (*L)->next=*L; return OK; }

Status ListEmpty_CL(LinkList L) { if(L->next==L) return TRUE; else return FALSE; }

int ListLength_CL(LinkList L) { int i=0; LinkList p=L->next; while(p!=L) { i++; p=p->next; } return i; }

Status GetElem_CL(LinkList L,int i,ElemType *e) { int j=1; LinkList p=L->next->next; if(i<=0||i>ListLength_CL(L)) return ERROR; while(j<i) { p=p->next; j++; } *e=p->data; return OK; }

int LocateElem_CL(LinkList L,ElemType e,Status(*compare)(ElemType,ElemType)) { int i=0; LinkList p=L->next->next; while(p!=L->next) { i++; if(compare(p->data,e)) return i; p=p->next; } return 0; }

Status PriorElem_CL(LinkList L,ElemType cur_e,ElemType *pre_e) { LinkList q,p=L->next->next; q=p->next; while(q!=L->next) { if(q->data==cur_e) { *pre_e=p->data; return TRUE; } p=q; q=q->next; } return FALSE; }

Status NextElem_CL(LinkList L,ElemType cur_e,ElemType *next_e) { LinkList p=L->next->next; while(p!=L) { if(p->data==cur_e) { *next_e=p->next->data; return TRUE; } p=p->next; } return FALSE; }

Status ListInsert_CL(LinkList *L,int i,ElemType e) { LinkList p=(*L)->next,s; int j=0; if(i<=0||i>ListLength_CL(*L)+1) return ERROR; while(j<i-1) { p=p->next; j++; } s=(LinkList)malloc(sizeof(struct LNode)); s->data=e; s->next=p->next; p->next=s; if(p==*L) *L=s; return OK; }

Status ListDelete_CL(LinkList *L,int i,ElemType *e) { LinkList p=(*L)->next,q; int j=0; if(i<=0||i>ListLength_CL(*L)) return ERROR; while(j<i-1) { p=p->next; j++; } q=p->next; p->next=q->next; *e=q->data; if(*L==q) *L=p; free(q); return OK; }

Status ListTraverse_CL(LinkList L,void(*vi)(ElemType)) { LinkList p=L->next->next; while(p!=L->next) { vi(p->data); p=p->next; } printf("\n"); return OK; } main() { int i; STUDENT *head; head=init(); clrscr(); for(;;) { switch(menu_list()) { case 0:InitList_CL();break; case 1:DestroyList_CL();break; case 2:ClearList_CL();break; case 3:ListEmpty_CL();break; case 4:ListLength_CL();break; case 5:GetElem_CL();break; case 6:LocateElem_CL(); break; case 7:PriorElem_CL();break; case 8: NextElem_CL(); break; case 9:ListInsert_CL();break; case 10:ListDelete_CL();break; case 11:ListTraverse_CL();break; case 12:exit(0); } } menu_list() { char *menu[]={"*****************************", "char1. InitList_CL", "char2. DestroyList_CL", "char3. ClearList_CL", "char4. ListEmpty_CL", "char5. ListLength_CL", "char6. GetElem_CL", "char7. LocateElem_CL", "char8. PriorElem_CL", "char9. NextElem_CL", "char10. ListInsert_CL", "char11. ListDelete_CL", "char12. ListTraverse_CL", "char13. Quit"}; } } 

搜索更多相关的解决方案: 高人  

----------------解决方案--------------------------------------------------------
兄弟
麻烦你说一说你的程序的用意好吧!有了目标别人才好给你看啊!!!!!!!!!!!!!!!!!
----------------解决方案--------------------------------------------------------
  相关解决方案