单链表问题

#include<stdio.h>
#include<stdlib.h>
#include<malloc.h>
typedef int DataType;
#include"123.h"

void main()
{
SLNode *head;
int i, x;
ListInitiate(&head);
for (i = 0;i < 10;i++)
{
if (ListInsert(head, i, i + 1) == 0)
{
printf("错误");
return;
}
}
if (ListDelete(head, 0, &x) == 0)
{
printf("错误\n");
return;
}
for (i = 0;i < ListLength(head);i++)
{
if (ListGet(head, i, &x) == 0)
{
printf("错误\0");
return;
}
else printf("%d", x);
}
printf("\n");
Destroy(&head);
system("pause");
}

这中间if (ListDelete(head, 0, &x) == 0) 能把第0个结点删除。
那头节点是第几个节点 头节点不是第0个节点 头节点不赋值的啊,为什么是删除第0个节点。

#include<stdio.h>
#include<stdlib.h>
#include<malloc.h>
typedef int DataType;
#include"123.h"//这个头文件需要发上来

void main() {
SLNode *head;
int i, x;
ListInitiate(&head);//head本身就是指针,那么&head传指针的地址是何意?
for (i = 0;i < 10;i++) {
if (ListInsert(head, i, i + 1) == 0) {//ListInsert()也得发上来,否则无法知道是如何操作的?
printf("错误\n");
return;
}
}
if (ListDelete(head, 0, &x) == 0) {
printf("错误\n");
return;
}
for (i = 0;i < ListLength(head);i++) {
if (ListGet(head, i, &x) == 0) {
printf("错误\0");
return;
}
else printf("%d", x);
}
printf("\n");
Destroy(&head);
system("pause");
}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2018-04-11
你自己画个图。实在是懒得看....
第2个回答  2018-03-31
看到就头痛,想起了大学
第3个回答  2018-03-31
不错
相似回答