#include<iostream>
using namespace std;
struct student
{
long num;
float score;
student *next;
} ;
int n;
int main()
{
student *creat(void);//建立链表函数声明
student *del(student *,long );//删除节点函数声明
student *insert(student *,student *);//插入数据函数声明
void print(student *);//输出函数声明
//定义结构体指针
student *head,*stu;
long del_num;
//——————————
cout<<"input records:"<<endl; //输出输入的链表数据
head=creat();
print(head);
//——————————
cout<<endl<<"input the deleted number:";//删除数据
cin>>del_num;
while(del_num!=0)//用循环结构连续删除数据
{
head=del(head,del_num);
print(head);
cout<<"input the deleted number:";
cin>>del_num;
}
//——————————
cout<<endl<<"input the inserted record:";//插入数据
stu=new student;
cin>>stu->num>>stu->score;
while(stu->num!=0)//用循环结构插入数据
{
head=insert(head,stu);
print(head);
cout<<endl<&
链表的建立、输出、删除和插入(大一些的综合题)
最新推荐文章于 2024-06-09 20:18:37 发布