学生管理系统
拥有多个函数,实现有增加学生成绩(偷懒使用随机数生成成绩),查询学生成绩,删除学生信息,
将学生成绩进行排序,显示学生的成绩信息,修改学生的成绩,销毁学生信息
可在原程序的基础上添加更多功能
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<string.h>
typedef struct node
{
int chinese;
int math;
int english;
int num;
char name[10];
struct node *prev;
struct node *next;
}node;
node *initlist(void)
{
node *new=malloc(sizeof(node));
if(new == NULL)
{
printf("malloc fail\n");
return NULL;
}
new->chinese=0;
int math=0;
int english=0;
new->num=0;
new->name[10];
new->next=new;
new->prev=new;
return new;
}
//从尾插入数据
void initlisthead1(node *head,node *new)
{
new->prev=head->prev;
new->next=head;
head->prev->next=new;
head->prev=new;
}
//查询学生的信息
node *find_data(node *head,int data)
{
node *p=NULL;
for(p=head->next;p!=head;p=p->next)
{
if(p->num == data)
{
return p;
}
}
return NULL;
}
//删除学生信息
node *del_data(node *head,int data)
{
node *del;
node *p;
del=find_data(head,data);
if(del == NULL)
{
return NULL;
}
del->prev->next=del->next;
del->next->prev=del->prev;
del->next=del;
del->prev=del;
return del;
}
//解除节点
void remo(node *head,node *q)
{
node*p=NULL;
for(p=head;p->next!=q;p=p->next);
p->next=q->next;
q->next=NULL;
}
//总分排序
void sort(node *head)
{
node *p=NULL;
node *tmp=NULL;
int len=0;
for(p=head->next;p!=head;p