关于链表的,有一些错误老是解决不了,大家帮忙看看

#include<stdio.h> /* EOF(=^Z或F6),NULL */
#include<process.h> /* exit() */
#include<malloc.h>
#include<math.h>
#define TRUE 1
#define FALSE 0
#define OK 1
#define ERROR 0
#define INFEASIBLE -1
#define int ElementType
typedef int Status; /* Status是函数的类型,其值是函数结果状态代码,如OK等 */
typedef int Boolean; /* Boolean是布尔类型,其值是TRUE或FALSE */
struct Node;
typedef  struct Node *PtrToNode;
typedef  PtrToNode List;
typedef  PtrToNode Position;
struct Node
{
   ElementType Element;
   Position  Next;
};

Position Find( ElementType X, List L )
{
 Position P;
 P=L->Next;
 while( P!=NULL&&P->Element!=X )
      P=P->Next;
 return P;
}

int ListLength(List L)
 { /* 初始条件:线性表L已存在。操作结果:返回L中数据元素个数 */
   int i=0;
  List p;
p=L->Node;  /* p指向第一个结点 */
   while(p) /* 没到表尾 */
   {
     i++;/* 元素个数加1 */
     p=p->next; /* 指针指向下一个元素 */
   }
   return i;
 }


Position FindPrevious( ElementType X, List L )
{
    Position P;

/* 1 */   P=L;
/* 2 */   while(P->Next !=NULL&& P->Next->Element !=X)
/* 3 */       P=P->Next;
/* 4 */   return P;
}

int IsLast(Position P, List L )
{
  return P->Next ==NULL;
}

void Delete(ElementType X, List L )
{
Position P,TmpCell;
P=FindPrevious( X , L );
if( !IsLast( P, L ))   /*Assumption of header use */
 {                     /* X is found; delete it */
    TmpCell=P->Next;//给指针TmpCell赋值
    P->Next=TmpCell->Next;//更改P->Next的值
    Free(TmpCell);//释放TmpCell所指向的结点
  }
}

void  Insert( ElementType X ,Position P )
{
          Position TmpCell;

/* 1 */   TmpCell=(Position)malloc( sizeof( struct Node ) );
/* 2 */   if(TmpCell == NULL )
/* 3 */      printf("Out of space!!!" );

/* 4 */  TmpCell-> Element =X;
/* 5 */   TmpCell->Next=P->Next;
/* 6 */   P->Next =TmpCell;
         }

Status ListTraverse(List L)
{ /* 初始条件:线性表L已存在 */
   List p=L-> Element;
   while(p)
   {
     printf("%d ", p-> Element); /* 输出元素 */
     p=p->Next; /* 指针指向下一个元素 */
   }
   printf("/n");
   return OK;
 }


void main(void)
 {
List L1;
Position P1;
int j,x;
L1=(List)malloc(sizeof(struct Node)); /* 产生头结点,并使L指向此头结点 */
   if(!L1) /* 存储分配失败 */
     exit(0);
L1->next=NULL; /*头结点的指针域的值为NULL */
printf("依次插入元素 33 58 66 76 88 99/n");
for(j=1;j<=6;j++)
{
scanf("%d",&x);//通过键盘为x赋值
Insert(x, P );//将元素x插入链表中
}
ListTraverse(L1) ;
P1= Find(66, L1 );
if(P1) 
printf("查找链表元素值为66的元素/n");
else printf("没找到/n");
Delete(88, L );//删除链表中值为88的元素
x=ListLength(L);//调用函数求链表的长度并赋给x
printf("链表表的长度是:%d/n", x);
printf("输出链表/n");
ListTraverse(L);//调用函数输出整个链表
}

 


错误:链表.cpp
D:/C++/C存放/链表.cpp(11) : error C2146: syntax error : missing ';' before identifier 'Status'
D:/C++/C存放/链表.cpp(11) : fatal error C1004: unexpected end of file found
执行 cl.exe 时出错.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值