当没有dummynode时实现链表头插 Posted on 2020-04-20 Words count in article: 93 | Reading time ≈ 1 如何实现链表的头插?12345678910111213// 链表一般是尾插的,那么怎么实现头插呢?void insertFromHead(ListNode* head){ //比如我要新插入一个节点 newNode,值为1; //先建立一个临时节点prev,让prev指向head ListNode* prev; ListNode* newNode; prev = head; //新建一个节点 newNode = new ListNode(1); //让新节点指向临时节点prev newNode->next = prev;} -------------本文结束,感谢您的阅读------------- Post author: Jason Post link: https://jasonxqh.github.io/2020/04/20/%E5%BD%93%E6%B2%A1%E6%9C%89dummynode%E6%97%B6%E5%AE%9E%E7%8E%B0%E9%93%BE%E8%A1%A8%E5%A4%B4%E6%8F%92/ Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 3.0 unless stating additionally.