编译很多错误,麻烦帮忙修改下。。
#include
#define MAXSIZE 100
typedef int Elemtype
typedef struct
{
Elemtype data[MAXSIZE];
int last;
}SeqList;
SeqList SeqListInit()//初始化顺序线性表
{
Seqlist L;
L.Last=0;
return L;
}
SeqList SeqListOnit(SeqList L)//对顺序线性表进行赋值
{
int i=0;
while(L.last
{
scanf("%d",data[i++]);
L.last++;
}
return L;
}
void SeqListlong(SeqList L)//输出顺序线性表的长度
{
printf("顺序线性表的长度为%d",L.last);
}
int SeqListLocate(SeqList L,Elemtype x)//查找顺序线性表中的某元素
{
int i=1;
while(i<=L.last&&L.data[i-1]!=x)
i++;
if(i<=L.last)return i;
else return 0;
}
int SeqListEmpty(SeqList L)//判断顺序线性表是否为空
{
return(L.last==0?1:0);
}
void SeqListclear(SeqList L)//清空顺序线性表
{
L.last=0;
}
SeqList SeqListsee(SeqList L)//遍历顺序线性表
{
int i=0;
printf("查看顺序线性表的结果为:\n"
for(i=0;i<=L.last;i++)
{
printf("%d ",L.data[i]);
}
}
SeqList SeqListInsert(SeqList L,int i,Elemtype x)//在顺序线性表插入某个数值
{
int j;
if(L.last==MAXSIZE)
printf("对不起,表已经满了,无法再插入");
if(i<1||i>L.last+1)
{
printf("插入位置错误");
exit(0);
}
for(j=L.last-1;j>=i-1;j--)
L.data[j+1]=L.data[j];
L.data[i-1]=x;
L.last++;
return L;
}
SeqList SeqListDetele(SeqList L,int i)//删除顺序线性表第i个数值
{
int j;
if(i<1||i>L.last)
{
printf("删除位置错误,退出");
exit(0);
}
for(j=i;j<=L.last-1;j++)
L.data[j-1]=L.data[j];
L.last--;
return L;
}
void main()
{
int c,b;
SeqList L;
L=SeqListInit();//初始化顺序线性表
printf("请对顺序线性表进行赋值,以#结束\n");
SeqListOnit(L);//对顺序线性表进行赋值
c=SeqListEmpty(L);//判断顺序线性表是否为空
if(c)
printf("表为空");
else printf("表不为空");
SeqListlong(L);//输出顺序线性表的长度
SeqListsee(L);//遍历顺序线性表
printf("请输入你要查找的元素\n");
scanf("%d",&c);
SeqListLocate(L,c);//查找顺序线性表中的某元素
printf("请输入你要插入的位置")
scanf("%d",&b);
printf("请输入你要插入的元素")
scanf("%d",&c);
SeqListInsert(L,b,c);
printf("请输入你要删除的元素");
scanf("%d",&c);
SeqListDetele(L,c);//删除顺序表中的某元素
SeqListclear(L);//清空顺序表
}