- 2024-01-17Inserting a node at nth position【1月17日学习笔记】
点击查看代码//Insertinganodeatnthposition#include<iostream>usingnamespacestd;structnode{intdata;node*next;};node*A;//全局头指针voidinsert(intx,intn){node*temp=newnode;//temp是局部变量,在stack区,每次调用更新temp-
- 2024-01-17Inserting a node at beginning,全局变量头指针【1月16日学习笔记】
点击查看代码//insertinganodeatbeginning,全局变量头指针#include<iostream>usingnamespacestd;structnode{ intdata; node*next;};node*A;voidinsert(intx){ node*temp=newnode;//创建新节点 temp->data=x; temp->next=A;//新节点尾巴指
- 2024-01-17Inserting a node at beginning,局部变量头指针版本1【1月16日学习笔记】
点击查看代码//insertinganodeatbeginning,局部变量头指针版本1#include<iostream>usingnamespacestd;structnode{ intdata; node*next;};node*insert(intx,node*A){ node*temp=newnode;//创建新节点 temp->data=x; temp->next=A;//新节
- 2024-01-17Inserting a node at beginning,局部变量头指针版本2【1月16日学习笔记】
点击查看代码//insertinganodeatbeginning,局部变量头指针版本2#include<iostream>usingnamespacestd;structnode{ intdata; node*next;};voidinsert(intx,node**A){ node*temp=newnode;//创建新节点 temp->data=x; temp->next=*A;//新