#include <bits/stdc++.h> // 引入标准头文件 using namespace std; // 使用命名空间std struct student { // 定义结构体student string name; // 字符串类型成员name struct student *next; // 结构体类型指针成员next }; // 结构体定义完毕 void printLink(struct student *head) // 定义函数printLink,参数为结构体类型指针head { struct student *p=head; // 定义结构体类型指针p,初始化为head while(p!=NULL) // 循环条件为p不为空 { cout<name<<"->"; // 输出p指向结构体的name成员,并输出箭头符号 p=p->next; // 将p指向下一个结构体 } cout<<"NULL"<<endl; // 输出NULL并换行 } // 函数定义完毕 int main() // 主函数开始 { struct student stu1,stu2,stu3,stu4,stu5,stu6,stu7,stu8; // 定义8个结构体类型的变量 stu1.name="赵"; // 给结构体变量赋值 stu2.name="钱"; stu3.name="孙"; stu4.name="李"; stu1.next=&stu2; // 将stu1的next指向stu2 stu2.next=&stu3; // 将stu2的next指向stu3 stu3.next=&stu4; // 将stu3的next指向stu4 stu4.next=NULL; // 将stu4的next置为NULL struct student *head=&stu1; // 定义结构体类型指针head,并将其指向stu1 printLink(head); // 调用函数printLink,输出链表中的元素

cout<<"4种节点插入可能"<<endl; // 输出提示信息 cout<<endl<<"1.节点插入到链表的最前面"<<endl; // 输出提示信息 stu5.name="周"; // 给结构体变量赋值 stu5.next=head; // 将stu5的next指向head head=&stu5; // 将head指向stu5 printLink(head); // 调用函数printLink,输出链表中的元素

return 0; // 返回0,结束程序 }逐句翻

#include bitsstdc++husing namespace std;struct student string name; struct student next;;void printLinkstruct student head struct student p=head; whilep!=NULL coutp-name-; p=p-next; coutNULLendl;i