#include  "stdafx.h"
#include<stdio.h>
#include<stdlib.h>
#define LEN sizeof(struct
#define
#define
typedef int
//定义LNode为结构体指针类型
typedef struct
ElemType data;
structNode *next;
intcount;
}*LinkList;
int

//输出当前链表的结点数据
int LinkList_print(LinkList L,intx)
{
LinkList p,q;
inta=x,b=1;
p=L;
"当前的链表为:\n");
while(b<=a)
{
if(b<a)
{q=p->next;
"%d-->",q->data);
p=q;}
elseif(b==a)
"%d",p->next->data);}
b++;
}
"\n");
returnOK;
}

//建立链表
int CreatList_L(LinkList L,intx)
{
LinkList p,q;
inta=x,b=1;
p=L;
structNode*)malloc(LEN);
while(b<=a)
{
if(b<a)
"请输入第%d个结点的数据\n",b);
"%d",&q->data);
p->next=q;
p=q;
structNode*)malloc(LEN);
}
elseif(b==a)
{
"请输入第%d个结点的数据\n",b);
"%d",&q->data);
p->next=q;
q->next=NULL;
}
b++;
}
LinkList_print(L,a);
returnOK;
}


//增加结点
int ListInsert_Sq(LinkList L,intx)
{
inta=x;
LinkList p=L,q;
L->count++;
while(a!=1){p=p->next;a--;}
structNode*)malloc(LEN);
"请输入要增加的结点的数据:\n");
"%d",&q->data);
q->next=p->next;
p->next=q;
LinkList_print(L,L->count);
returnOK;
}

//删除结点
int ListDelete_L(LinkList L,intx)
{
inta=x;
LinkList p=L,q;
L->count--;
while(a!=1){p=p->next;a--;}
q=p->next;
p->next=q->next;
"删除的结点为:\n%d\n",q->data);
free(q);
LinkList_print(L,L->count);
returnOK;
}

//查找结点
int Seek(LinkList L,int
{
inta=x,b=L->count,c=1;
LinkList p=L;
while(b!=0)
{p=p->next;
if(a==p->data)
"这是第%d个结点\n",c);
b--;c++;
}
returnOK;
}

//链表倒置
int
{
LinkList p=L,q=L;
int*w,*c;
inta=L->count;
int*)malloc(L->count*sizeof(int));
for(c=w;c<w+L->count;c++)
{p=p->next;*c=p->data;}
for(c=w+L->count-1;c>=w;c--)
{q=q->next;q->data=*c;}
LinkList_print(L,L->count);
returnOK;
}


//主函数
void
{
LinkList L;
intt;
structNode*)malloc(LEN);
"请输入链表L的结点个数:\n");
"%d",&L->count);
CreatList_L(L,L->count);
intflag=1,select;
"====================菜单============================\n");
"= 1.增加结点 =\n");
"= 2.删除结点 =\n");
"= 3.查找结点 =\n");
"= 4.链表倒置 =\n");
"= 5.退出操作 =\n");
"================支持乱序选择========================\n");
while(flag){
"\n请选择菜单中的操作选项:\n");
"%d",&select);
switch(select)
{
case1:
"请输入要插入的结点位置(使之成为第几个结点):\n");
"%d",&t);
break;
case2:
"请输入要删除的结点位置(删除第几个结点):\n");
"%d",&t);
break;
case3:
"请输入要查找的结点的数据(显示它的位置是第几个):\n");
"%d",&t);
break;
case4:
"倒置后的链表为:\n");
break;
case5:
break;
default:printf("您输入的数据有误!\n");
}

}

}