1、#include “stdafx.h“#includeusing namespace std;int ERROR=0;int OK=1;typedef int ElemType;typedef int Status;typedef struct LNodeElemType data;struct LNode *next;LNode,*LinkList;Status InitList_L(LinkList L-next=NULL;return OK;Status GetElem_L(LinkList L,int i,ElemType p=L-next;int j=1;couti;while(p+
2、j;if(!p|ji) return ERROR;e=p-data;return OK;LNode *LocateELem_L(LinkList L,ElemType e) /按值查找 int m=1;coutnext;cine;while(pm=m+1;if(p-data=e)couti;coute;while(p+j;if(!p|jdata=e;s-next=p-next;p-next=s;return OK;Status ListDelete_L(LinkList p=L;int j=0;couti;while(p-next+j;if(!(p-next)|ji-1) return ERR
3、OR;q=p-next;p-next=q-next;e=q-data;delete q;return OK;void CreateList_F(LinkList LNode *p;L=new LNode;L-next=NULL;coutn;cout0;-i)p=new LNode;cinp-data;p-next=L-next;L-next=p;coutnext=NULL;r=L;int i;coutn;coutp-data;p-next=NULL;r-next=p;r=p;coutnext;while(p)coutdatanext;couti;switch(i)case 1:int a;co
4、uta;switch(a)case 1:int n;CreateList_F(L,n);break;case 2:CreatList_L(L,n);break;default:coutb;switch(b)case 1:*LocateELem_L(L,e);break;case 2:GetElem_L(L,i,e);break;default:cout“请重新输入 :“endl;break;case 3:ListInsert_L(L,i,e);print(L);break;case 4:ListDelete_L(L,i,e);print(L);default:cout“请重新输入:“endl;printf(“Hello World!n“);return 0;