#include <iostream>
#include <cstdlib>
#include <ctime>
#include <string.h>
#include <iomanip> //操作符的头文件
using namespace std;
class list
{
public:
int num,score;
char name[10];
class list *next;
};
typedef class list node;
typedef node *link;
link findnode(link head,int num)
{
link ptr;
ptr=head;
while(ptr!=NULL)
{
if(ptr->num==num)
return ptr;
ptr=ptr->next;
}
return ptr;
}
link insertnode(link head,link ptr,int num,int score,char name[10])
{
link InsertNode;
InsertNode=new node;
if(!InsertNode)
return NULL;
InsertNode->num=num;
InsertNode->score=score;
strcpy(InsertNode->name,name);
InsertNode->next=NULL;
if(ptr==NULL) //插入第一个节点
{
InsertNode->next=head;
return InsertNode;
}
else
{
if(ptr->next=&
单向链表插入新节点
最新推荐文章于 2022-12-30 14:37:18 发布