单链表创建面试题:
1. 从尾到头打印单链表
2. 删除一个无头单链表的非尾节点(不能遍历链表)
3. 在无头单链表的一个非头节点前插入一个节点(不能遍历链表)
4. 单链表实现约瑟夫环(JosephCircle)
5. 逆置/反转单链表
6. 查找单链表的中间节点,要求只能遍历一次链表
void PrintListTail2Head(pNode head)//倒着打印
{
if(head)
{
PrintListTail2Head(head->next);
printf("%d-->",head->data);
}
}
void DelNotTailNode(pNode head,pNode pos)//不遍历删除非尾节点
{
pNode del;
if(!head || !pos || !pos->next)
return;
del = pos->next;
pos->data = del->data;
pos->next = del->next;
free(del);
}
void InsterNotErg(pNode *head,pNode pos,DateType e)//不遍历在结点前插入
{
pNode nd;
assert(head);
if(!pos)
return;
nd = BuyNode(pos->data);
if(nd)
{
pos->data = e;
nd->next = pos->next;
pos