学⽣信息管理系统html代码,学⽣信息管理系统源代码.doc #include
#include
#include
#define LEN sizeof(student)
struct stu
{
int sno;
char name[20];
char gender;
float score[5];
float avg;
float sum;
struct stu *next;
};
typedef struct stu student;
void input(student *p)
{
html导航源码if(p==NULL) return;
printf("请输⼊学⽣学号:\n");
scanf("%d",&p->sno);
getchar();
printf("请输⼊学⽣姓名:\n");
gets(p->name);
printf("请输⼊学⽣性别:\n");
p->gender=getchar();
printf("请分别输⼊学⽣五门成绩\n");
scanf("%f%f%f%f%f",&p->score[0],&p->score[1],&p->score[2],&p->score[3],&p->score[4]);
p->sum = p->score[0]+p->score[1]+p->score[2]+p->score[3]+p->score[4];
p->avg = p->sum/5;
}
void output(student *p)
{
printf("%d %s %c %.2f %.2f %.2f %.2f %.2f\n",p->sno,p->name,p->gender,p->score[0],p->score[1],p->score[2],p->avg,p->sum);
}
void outputs(student *p)
{
p=p->next;
while(p!=NULL)
{
output(p);
p=p->next;
}
}
student * create (int n)
{
student * pHead = (student *)malloc(LEN);
student *pNew,*pTail;
int i;
pHead->next=NULL;
pTail=pHead;
for(i=0;i
{
pNew=(student *)malloc(LEN);
if(pNew==NULL)return pHead;
input(pNew);
pTail->next = pNew;
pNew->next=NULL;
pTail=pNew;
}
return pHead;
}
int del(student *pHead,int sno) //根据学号删除学⽣结点
{
student *p,*q;//p指向要删除的学⽣结点 q指向要删除学⽣结点的上⼀个结点
p=pHead->next;
q=pHead;
while(p->sno!=sno && p!=NULL)
{
p=p->next;
q=q->next;
}
if(p!=NULL)
{
q->next = p->next;
free(p);
return 0;//0表⽰删除成功,EOF表⽰删除不成功,没有到}else
{
printf("输⼊有误\n");
return EOF;
}
}
void destroy(student *pHead)
{
student *p,*q;
p=pHead;
while(p!=NULL)
{
q=p->next;
free(p);
p=q;
}
}
int saveBinary(student *pHead, char *filename)
{
FILE *fp = fopen(filename,"wb");
if(!pHead || !pHead->next || !fp) return EOF;
student *p=pHead->next;
while(p!=NULL)
{
fwrite(p,LE
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论