C语言 读取线性表中的第i个元素,GetElem(struct Sqlist MyList, in
发布网友
发布时间:2022-05-10 22:53
我来回答
共1个回答
热心网友
时间:2023-11-10 08:51
struct Sqlist {
ElemType data;
struct Sqlist *next;
};
void GetElem(struct Sqlist MyList,int i,ElemType *e)
{
struct Sqlist *p=MyList->next;
int n=0;
while(p){
p=p->next;n++;
}
p=MyList->next;
for(int j=0;j<n-i;j++)
p=p->next;
*e=p->data;
}