C语言一个完整的插入和删除操作

来源:百度知道 编辑:UC知道 时间:2024/05/11 13:15:57
急要一个C语言的链表的插入删除操作.
邮箱:249898499@qq.com
谢谢....
不要在网上找的哦....要自己写的哦...谢谢.写得好还可以加分

# include "iostream.h"
# include "stdlib.h"
# include "string.h"
# define NULL 0
# define FEN sizeof(struct student)
int a;
struct student{ //定义链表
int num;
char name[15];
struct student *next;
};
struct student * creat(){ //创建链表 停止输入把num输入为0 name正常输入即可
struct student *head,*p1,*p2;
head=NULL;
p1=p2=(struct student *)malloc(FEN);
cout<<"input num and name\n";
cin>>p1->num;
cin>>p1->name;
for(a=1;p1->num!=0;a++){
if(a==1) head=p1;
else p2->next=p1;
p2=p1;
p1=(struct student *)malloc(FEN);
cin>>p1->num;
cin>>p1->name;
}
p2->next=NULL;
return(head);
}
void shuchu(struct student *head){ //输出链表
struct student *p1;
p1=head;
for(;p1!=NULL;p1=p1->next)