动态单链表基本运算的实现

来源:百度知道 编辑:UC知道 时间:2024/06/14 00:55:04
题目:1、首先创建一个新链表,输出新链表各个结点数据
2、插入一个新结点,再输出链表的各个结点数据
(1)结点的数据结构定义如下:
typedef struct studentnode
{ int stdnum; //学号,例如:2070501001
int stdscore; //计算机成绩,例如:92
struct studentnode *next //指针域
} Node;
(2)创建链表、输出结点数据以及结点插入等运算均要求用自定义函数实现

总结:主要所涉及知识点的理解

typedef struct studentnode
{ int stdnum; //ѧºÅ£¬ÀýÈ磺2070501001
int stdscore; //¼ÆËã»ú³É¼¨£¬ÀýÈ磺92
struct studentnode *next; //Ö¸ÕëÓò
} Node;
Node* Createlist(int N)
{
Node* List=new Node;
cout<<"Please input information:"<<endl<<"Number:";
cin>>List->stdnum;
cout<<"Score:";
cin>>List->stdscore;
List->next=NULL;
Node* tempList=List;
for(int i=1;i<N;i++)
{
Node* List_p=new Node;
cout<<"Please input information:"<<endl<<"Number:";
cin>>List_p->stdnum;
cout<<"Score:";
cin>>List_p->stdscore;
List-