我写了这个程序,它应该从用户输入创建一个整数的链接列表,直到用户插入’0’,打印它,在它的末尾添加一个元素,然后再次打印链表,…
你错了 procedure CreateList(); 因为你将新记录添加到开头而不是结尾。 RefEnd 还是 nil 后 CreateList() 。
procedure CreateList();
RefEnd
nil
CreateList()
然后你打电话 InsertElement(5,RefBeginning,RefEnd); 同 RefEnd = nil 在线上触发错误 outRefEnd^.next := RefNew; 作为参数 outRefEnd 没有。
InsertElement(5,RefBeginning,RefEnd);
RefEnd = nil
outRefEnd^.next := RefNew;
outRefEnd
你应该纠正 CreateList() 基本上与...类似的程序 InsertElement 关于将初始项目与两者联系起来 outRefBeginning 和 outRefEnd 和随后的新项目 outRefEnd 。
InsertElement
outRefBeginning