本程序为完全个人理解所写。
因英语不好大部分用拼音代替。
#includeusing namespace std; typedef struct LNode{ //链表结构 int data; LNode *next; }LNode,*linkList; bool cj(linkList &L); void qk(linkList &L); void cd(linkList &L); void cr(linkList &L,int i,int a); void bl(linkList &L); void wcf(linkList &L,int a); void pk(linkList &L); void cz(linkList &L,int a); void sc(linkList &L,int a); int main(){ linkList L; int a,wz,z; for(int i=0;i<100;){ cout<<"1初始化线性表 2清空线性表"<<"n"; cout<<"3求线性表长度 4插入元素"<<"n"; cout<<"5遍历线性表 6尾插法"<<"n"; cout<<"7判空 8查找"<<"n"; cout<<"9删除"<<"n"; cin>>a; if(a==1)cj(L); if(a==2)qk(L); if(a==3)cd(L); if(a==4){ cout<<"请输入插入的位置与值"<<"n"; cin>>wz>>z; cr(L,wz,z); } if(a==5){ bl(L); } if(a==6){ cout<<"请输入长度"<<"n"; cin>>z; wcf(L,z); } if(a==7){ pk(L); } if(a==8){ cout<<"请输入要查找的数"<<"n"; cin>>z; cz(L,z); } if(a==9){ cout<<"请输入要删除那个位置的数"<<"n"; cin>>z; sc(L,z); } } } bool cj(linkList &L){//初始化线性? L=new LNode; L->next=NULL; return true; } void qk(linkList &L){//清空线性表 L->next=NULL; } void cd(linkList &L){//求线性表长? linkList p; int a=0; p=L; while(p->next!=NULL){ p=p->next; ++a; } cout<<"长度为"next; } p->next=r->next; r->next=p; } void bl(linkList &L){//遍历线性表 linkList p; p=L->next; while(p->next!=NULL){ cout< data<<"n"; p=p->next; } cout< data<<"n"; } void wcf(linkList &L,int a){//尾插? linkList r,p; r=L; cout<<"输入数"<<"n"; for(int i=0;i>p->data; p->next=NULL; r->next=p; r=p; } } void pk(linkList &L){//判? if(L->next==NULL){ cout<<"为空"<<"n"; }else{ cout<<"不为空"<<"n"; } } void cz(linkList &L,int a){//查? linkList p; int x=1; p=L->next; while(p->data!=a&&p->next!=NULL){ p=p->next; ++x; } if(p->next==NULL){ cout<<"表中没有这个数"<<"n"; } if(p->data==a){ cout<<"表中的这个数在第"< next->next; r->next=p; }



