void ListInitiate(SLNode** head) {
*head = (SLNode*)malloc(sizeof(SLNode));
(*head)->next = NULL;
}
int ListLength(SLNode* head) {
SLNode* p = head;
int size=0;
while (p->next != NULL) {
p = p->next;
size++;
}
return size;
}
int ListInsert(SLNode* head, int i, DataType x) {
SLNode* p, * q;
int j;
p = head;
j = -1;
while (p->next != NULL && j < i - 1) {
p = p->next;
j++;
}
if (j != i - 1) {
printf("插入元素位置参数错误");
return 0;
}
q = (SLNode*)malloc(sizeof(SLNode));
q->data = x;
评论0
最新资源