#include "stdio.h"
void main()
{
printf("hello");
}
#include "Linklistp.h"
#include "stdio.h"
void ListInitialize(SequenceList *L)
{
L->age=0;
}
int ListLength(SequenceList L)
{
return L.age;
}
int ListInsert(SequenceList *L,int i,ElemType x)
{
int j;
if(L->age>=MaxSize)
{
printf("顺序表无法插入\n");
return 0;
}
else if(i<0||i>L->age)
{
printf("参数i不合法\n");
return 0;
}
else
{
for(j=L->age;j>i;j--)
L->list[j]=L->list[j-1];
L->list[i]=x;
L->age ++;
return 1;
}
}
int ListDelete(SequenceList *L,int i,ElemType *x)
{
int j;
if(L->age<=0)
{
printf("顺序表无数据可删\n");
return 0;
}
else if(i<0||i>L->age-1)
{
printf("参数i不合法\n");
return 0;
}
else
{
*x=L->list[i];
for(j=i+1;j<=L->age-1;j++)
L->list[j-1]=L->list[j];
L->age--;
return 1;
}
}
void ListDisplay(SequenceList *L)
{
for(int i=0;i<L->age;i++)
cout<<L->list[j]<<'';
printf("\n");
}
typedef int ElemType;
typedef struct
{
ElemType list[MaxSize];
int age;
}SequenceList;
void ListInitialize(SequenceList *L)
int ListLength(SequenceList L)
int ListInsert(SequenceList *L,int i,ElemType x)
int ListDelete(SequenceList *L,int i,ElemType *x)
void ListDisplay(SequenceList *L)
我做的是线性表的顺序表的初始化,插入,删除,还有表的输出,如果可以的话能不能也顺便告诉我怎么把两个线性表中求2个线性表共同的元素,并输出。
Compiling.
Linklista.cpp
d:\linklistp.h(4) : error C2065: 'MaxSize' : undeclared identifier
d:\linklistp.h(4) : error C2057: expected constant expression
d:\linklistp.h(4) : warning C4200: nonstandard extension used : zero-sized array in struct/union
d:\linklistp.h(5) : error C2229: struct '__unnamed' has an illegal zero-sized array
d:\linklistp.h(8) : warning C4518: 'int ' : storage-class or type specifier(s) unexpected here; ignored
d:\linklistp.h(8) : error C2146: syntax error : missing ';' before identifier 'ListLength'
d:\linklistp.h(8) : fatal error C1004: unexpected end of file found
执行 cl.exe 时出错.
Linklista.obj - 1 error(s), 0 warning(s)
这是编译结果
这是工作区