c语言程序设计学生管理系统.docx
《c语言程序设计学生管理系统.docx》由会员分享,可在线阅读,更多相关《c语言程序设计学生管理系统.docx(23页珍藏版)》请在冰豆网上搜索。
c语言程序设计学生管理系统
/*学生成绩管理系统
数据库的数据项主要数据包括:
学号、姓名、年级、专业、成绩 1、成绩 2、成绩 3、平均
成绩、总成绩。
要求具有以下功能:
(1)添加、删除任意个记录。
(2)修改任意个记录。
(3)显示、保存记录。
(4)排序功能:
打开学生数据库,计算每个学生的平均成绩和总成绩,用冒泡法或选择排
序法将平均成绩和总成绩排序后生成两个新文件(从大到小),
存盘并显示这两个文件的全部记录。
(5)查询功能:
打开总成绩排序文件,用折半查找法统计出给定分数的人数并显示。
要求:
(1)设计一个主函数和多个子函数,每个子函数完成一个相对独立的子功能。
(2)程序运行时,首先进行口令检查,再显示菜单。
并能根据菜单调用相应的函数功能。
口令程序段的功能要求:
《1》提示用户输入一个口令。
《2》用户输入口令后,若口令对,则提示用户通过,可执行后续程序;否则不通过。
《3》可对用户的口令输入进行次数限制(如:
重复输入 3 次都不对),则自动退出系
统。
*/
#include
struct student
{
int num;
char name[10];
int grade;
char major[10];
float score_1,score_2,score_3,aver,total;
struct student *next;
};
struct student *creat(void);
struct student *add(void);
struct student *del(int num);
struct student *alter();
void save(struct student *head);
void read();
void totalsort(struct student *head);
void aversort(struct student *head);
void Bfindsort();
int all=0;
void main()
int i,n,m,num;
char ord[10]="student",ord_1[10];
struct student *p;
for(i=0;i<=3;i++)
if(i==3)
exit(0);
printf("请第%d 次输入进入系统的指令:
",i+1);
scanf("%s",ord_1);
if(strcmp(ord,ord_1)!
=0)
printf("输入的指令有误请重新输入。
\n");
if(strcmp(ord,ord_1)==0)
break;
}
p=NULL;
loop_2:
printf("输入系统的功能:
\n0、建立一个数据库;\n1、添加与保存学生数据;\n2、删
除与保存学生数据;\n3、修改与保存学生数据;\n4、显示数据库的记录;\n5、将数据进
行排序;\n6、查询指定成绩的人数:
");
loop:
scanf("%d",&n);
if(n<0||n>6)
printf("\n 输入的选择有误请重新输入:
goto loop;
if(n==2)
printf("输入删除学生数据的学号:
scanf("%d",&num);
switch(n)
case 0:
p=creat();save(p);read();break;
case 1:
p=add();save(p);read();break;
case 2:
p=del(num);save(p);read();break;
case 3:
p=alter();save(p);read();break;
case 4:
read();break;
case 5:
printf("输入选择排序的功能 1、根据平均成绩;2、根据总成绩:
loop_1:
scanf("%d",&m);
if(m<1||m>2)
goto loop_1;
switch(m)
aversort(p);break;
totalsort(p);break;
}break;
case 6:
Bfindsort();break;
loop_5:
printf("输入你要进行的步骤:
1、返回上一菜单菜单;2、退出程序。
if(n<1||n>2)
printf("输入的选择有误,请重新输入:
goto loop_5;
goto loop_2;break;
struct student *creat(void)
int i,n;
struct student *head,*p,*q,*tail;
printf("输入学生的个数:
head=NULL;
for(i=0;i{all++;p=(struct student*)malloc(sizeof(struct student));if(head==NULL)head=p;elsetail->next=p;tail=p;p->next=NULL;q=head;printf("输入学生的学号、名字、年级、专业、三门成绩:");scanf("%d %s %d %s %f %f %f",&p->num,&p->name,&p->grade,&p->major,&p->score_1,&p->score_2,&p->score_3);loop: while(q->next!=NULL){if(q->num==p->num){printf("输入的学生号错误请重新输入学生学号:");scanf("%d",&p->num);goto loop;}q=q->next;}p->aver=(p->score_1+p->score_2+p->score_3)/3;p->total=p->score_1+p->score_2+p->score_3;}return(head);}void save(struct student *head){struct student *p;FILE *fp;if((fp=fopen("student.txt","wb"))==NULL){printf("打开文件失败。\n");exit(0);}p=head;while(p!=NULL){fwrite(p,sizeof(struct student),1,fp);p=p->next;}fclose(fp);}struct student *del(int num){int i,n=0;struct student *p,*q,*head;FILE *fp;if(all==0){printf("数据库为空。\n");head=NULL;return(head);}p=(struct student *)malloc(sizeof(struct student));if((fp=fopen("student.txt","rb"))==NULL){printf("打开 student.txt 文件失败\n");exit(0);}for(i=0;p!=NULL;i++){p=(struct student *)malloc(sizeof(struct student));fread(p,sizeof(struct student),1,fp);if(i==0)head=p;if(num==p->num){if(p==head)head=p->next;elseq->next=p->next;n++;all--;}q=p;}if(n==0)printf("没有%d 这一学生号的学生!\n",num);return(head);}struct student *add(){int i,j,m,n=0;FILE *fp;struct student *p,*q,*temp,*head,*tail;if(all==0){head=NULL;}else{if((fp=fopen("student.txt","rb"))==NULL){printf("打开 student.txt 文件失败\n");exit(0);}p=(struct student*)malloc(sizeof(struct student));fread(p,sizeof(struct student),1,fp);head=p;tail=p;while(p->next!=NULL){p=(struct student*)malloc(sizeof(struct student));fread(p,sizeof(struct student),1,fp);tail->next=p;tail=p;}tail->next=NULL;fclose(fp);}printf("输入需要输入学生的个数:");scanf("%d",&j);for(i=0;i{all++;p=(struct student*)malloc(sizeof(struct student));printf("输入学生的学号、名字、年级、专业、三门成绩:");scanf("%d %s %d %s %f %f %f",&p->num,&p->name,&p->grade,&p->major,&p->score_1,&p->score_2,&p->score_3);temp=head;loop_1: while(temp!=NULL){if(temp->num==p->num){printf("输入的学生号错误请重新输入学生学号:");scanf("%d",&p->num);goto loop_1;}temp=temp->next;}p->aver=(p->score_1+p->score_2+p->score_3)/3;p->total=p->score_1+p->score_2+p->score_3;if(head==NULL){head=p;p->next=NULL;}else{q=head;n=1;while(q->next!=NULL){q=q->next;n++;}printf("该链表一共有节点个数%d。\n",n);loop:printf("输入将数据插入第几个节点后面。\n");scanf("%d",&m);if(m<0||m>n){printf("输入有误,请重新输入。\n");goto loop;}q=head;if(m==0){p->next=head;head=p;}else{while((m-1)!=0){q=q->next;m--;}p->next=q->next;q->next=p;}}}return(head);}struct student *alter(){int m,num,gra,n;char maj[10],name[10];float score_1,score_2,score_3;struct student *p,*q,*head;FILE *fp;if(all==0){printf("数据库为空。\n");head=NULL;return(head);}if((fp=fopen("student.txt","rb"))==NULL){printf("打开 student.txt 文件失败\n");exit(0);}p=(struct student*)malloc(sizeof(struct student));fread(p,sizeof(struct student),1,fp);head=p;q=p;loop_1:printf("输入修改学生数据的姓名:");scanf("%s",&name);while(strcmp(name,p->name)!=0){p=p->next;if(p==NULL){printf("没有该学生。\n");return(head);}}loop:printf("请选择修改学生的具体数据:\n1、学号;2、年级;3、专业;\n4、成绩1;5、成绩 2;6、成绩 3:");scanf("%d",&m);if(m<1||m>6){printf("\n 输入的选择有误请重新输入:");goto loop;}switch(m){case 1:printf("输入新的学号:");loop_2:scanf("%d",&num);while(q!=NULL){if(q->num==num){printf("输入的学生号错误请重新输入学生学号:");goto loop_2;}q=q->next;}p->num=num;break;case 2:printf("输入新的年级:");scanf("%d",&gra);p->grade=gra;break;case 3:printf("输入新的专业:");scanf("%s",&maj);strcpy(p->major,maj);break;case 4:printf("输入新的成绩:");scanf("%f",&score_1);p->score_1=score_1;p->aver=(p->score_1+p->score_2+p->score_3)/3;p->total=p->score_1+p->score_2+p->score_3; break;case 5:printf("输入新的成绩:");scanf("%f",&score_2);p->score_2=score_2;p->aver=(p->score_1+p->score_2+p->score_3)/3;p->total=p->score_1+p->score_2+p->score_3;break;case 6:printf("输入新的成绩:");scanf("%f",&score_3);p->score_3=score_3;p->aver=(p->score_1+p->score_2+p->score_3)/3;p->total=p->score_1+p->score_2+p->score_3;break;}printf("选择你要执行的内容:\n1、返回上一菜单\n2、返回主菜单\n3、修改另一学生的数据");loop_5: scanf("%d",&n);if(n<1||n>3){printf("输入的选择有误,请重新输入:");goto loop_5;}switch(n){case 1:goto loop;break;case 2:break;case 3:goto loop_1;break;}return(head);}void read(){struct student *p,*head;FILE *fp;if(all==0){printf("系统没有学生数据。\n");return;}if((fp=fopen("student.txt","rb"))==NULL){printf("打开文件失败。\n");exit(0);}p=(struct student*)malloc(sizeof(struct student));fread(p,sizeof(struct student),1,fp);head=p;printf("打开 student.txt 文件的学生数据。\n");printf("listnum name grade major score_1 score_2 score_3 aver total\n");while(p!=NULL){printf("student %-3d %-4s %-5d %-5s %-7.2f %-7.2f %-7.2f %-4.2f %-5.2f \n",p->num,p->name,p->grade,p->major,p->score_1,p->score_2,p->score_3,p->aver,p->total);p=p->next;}fclose(fp);}void aversort(struct student *head){int temp;float temp_1;char temp_2[10];struct student *p,*q,*i;FILE *fp;p=head;while(p->next!=NULL){q=p;i=p->next;while(i!=NULL){if(i->aver>q->aver)q=i;i=i->next;}if(q!=p){temp=p->num;p->num=q->num;q->num=temp;strcpy(temp_2,p->name);strcpy(p->name,q->name);strcpy(q->name,temp_2);temp=p->grade;p->grade=q->grade;q->grade=temp;strcpy(temp_2,p->major);strcpy(p->major,q->major);strcpy(q->major,temp_2);temp_1=p->score_1;p->score_1=q->score_1;q->score_1=temp_1;temp_1=p->score_2;p->score_2=q->score_2;q->score_2=temp_1;temp_1=p->score_3;p->score_3=q->score_3;q->score_3=temp_1;temp_1=p->aver;p->aver=q->aver;q->aver=temp_1;temp_1=p->total;p->total=q->total;q->total=temp_1;}p=p->next;}if((fp=fopen("student_1.txt","wb+"))==NULL){printf("打开 student_1.txt 文件失败\n");exit(0);}p=head;while(p!=NULL){fwrite(p,sizeof(struct student),1,fp);p=p->next;}p=head;rewind(fp);printf("读出由平均成绩排序出来的文件 student_1.txt。\n");printf("listnum name grade major score_1 score_2 score_3 aver total\n");while(p!=NULL){fread(p,sizeof(struct student),1,fp);printf("student %-3d %-4s %-5d %-5s %-7.2f %-7.2f %-7.2f %-4.2f %-5.2f \n",p->num,p->name,p->grade,p->major,p->score_1,p->score_2,p->score_3,p->aver,p->total);p=p->next;}fclose(fp);}void totalsort(struct student *head){int temp;float temp_1;char temp_2[10];struct student *p,*q,*i;FILE *fp;p=head;while(p->next!=NULL){q=p;i=p->next;while(i!=NULL){if(i->total>q->total)q=i;i=i->next;}if(q!=p){temp=p->num;p->num=q->num;q->num=temp;strcpy(temp_2,p->name);strcpy(p->name,q->name);strcpy(q->name,temp_2);temp=p->grade;p->grade=q->grade;q->grade=temp;strcpy(temp_2,p->major);strcpy(p->major,q->major);strcpy(q->major,temp_2);temp_1=p->score_1;p->score_1=q->score_1;q->score_1=temp_1;temp_1=p->score_2;p->score_2=q->score_2;q->score_2=temp_1;temp_1=p->score_3;p->score_3=q->score_3;q->score_3=temp_1;temp_1=p->aver;p->aver=q->aver;q->aver=temp_1;temp_1=p->total;p->total=q->total;q->total=temp_1;}p=p->next;}if((fp=fopen("student_1.txt","wb+"))==NULL){printf("打开 student_1.txt 文件失败\n");exit(0);}p=head;while(p!=NULL){fwrite(p,sizeof(struct student),1,fp);p=p->next;}p=head;rewind(fp);printf("读出由平均成绩排序出来的文件 student_1.txt。\n");printf("listnum name grade major score_1 score_2 score_3 aver total\n");while(p!=NULL){fread(p,sizeof(struct student),1
all++;
p=(struct student*)malloc(sizeof(struct student));
if(head==NULL)
head=p;
else
tail->next=p;
tail=p;
p->next=NULL;
q=head;
printf("输入学生的学号、名字、年级、专业、三门成绩:
scanf("%d %s %d %s %f %f %f",&p->num,&p->name,&p->grade,&p->major,&p-
>score_1,&p->score_2,&p->score_3);
while(q->next!
=NULL)
if(q->num==p->num)
printf("输入的学生号错误请重新输入学生学号:
scanf("%d",&p->num);
q=q->next;
p->aver=(p->score_1+p->score_2+p->score_3)/3;
p->total=p->score_1+p->score_2+p->score_3;
return(head);
void save(struct student *head)
FILE *fp;
if((fp=fopen("student.txt","wb"))==NULL)
printf("打开文件失败。
p=head;
while(p!
fwrite(p,sizeof(struct student),1,fp);
p=p->next;
fclose(fp);
struct student *del(int num)
int i,n=0;
struct student *p,*q,*head;
if(all==0)
printf("数据库为空。
p=(struct student *)malloc(sizeof(struct student));
if((fp=fopen("student.txt","rb"))==NULL)
printf("打开 student.txt 文件失败\n");
for(i=0;p!
=NULL;i++)
fread(p,sizeof(struct student),1,fp);
if(i==0)
if(num==p->num)
if(p==head)
head=p->next;
q->next=p->next;
n++;
all--;
q=p;
if(n==0)
printf("没有%d 这一学生号的学生!
\n",num);
struct student *add()
int i,j,m,n=0;
struct student *p,*q,*temp,*head,*tail;
while(p->next!
tail->next=NULL;
printf("输入需要输入学生的个数:
scanf("%d",&j);
for(i=0;i{all++;p=(struct student*)malloc(sizeof(struct student));printf("输入学生的学号、名字、年级、专业、三门成绩:");scanf("%d %s %d %s %f %f %f",&p->num,&p->name,&p->grade,&p->major,&p->score_1,&p->score_2,&p->score_3);temp=head;loop_1: while(temp!=NULL){if(temp->num==p->num){printf("输入的学生号错误请重新输入学生学号:");scanf("%d",&p->num);goto loop_1;}temp=temp->next;}p->aver=(p->score_1+p->score_2+p->score_3)/3;p->total=p->score_1+p->score_2+p->score_3;if(head==NULL){head=p;p->next=NULL;}else{q=head;n=1;while(q->next!=NULL){q=q->next;n++;}printf("该链表一共有节点个数%d。\n",n);loop:printf("输入将数据插入第几个节点后面。\n");scanf("%d",&m);if(m<0||m>n){printf("输入有误,请重新输入。\n");goto loop;}q=head;if(m==0){p->next=head;head=p;}else{while((m-1)!=0){q=q->next;m--;}p->next=q->next;q->next=p;}}}return(head);}struct student *alter(){int m,num,gra,n;char maj[10],name[10];float score_1,score_2,score_3;struct student *p,*q,*head;FILE *fp;if(all==0){printf("数据库为空。\n");head=NULL;return(head);}if((fp=fopen("student.txt","rb"))==NULL){printf("打开 student.txt 文件失败\n");exit(0);}p=(struct student*)malloc(sizeof(struct student));fread(p,sizeof(struct student),1,fp);head=p;q=p;loop_1:printf("输入修改学生数据的姓名:");scanf("%s",&name);while(strcmp(name,p->name)!=0){p=p->next;if(p==NULL){printf("没有该学生。\n");return(head);}}loop:printf("请选择修改学生的具体数据:\n1、学号;2、年级;3、专业;\n4、成绩1;5、成绩 2;6、成绩 3:");scanf("%d",&m);if(m<1||m>6){printf("\n 输入的选择有误请重新输入:");goto loop;}switch(m){case 1:printf("输入新的学号:");loop_2:scanf("%d",&num);while(q!=NULL){if(q->num==num){printf("输入的学生号错误请重新输入学生学号:");goto loop_2;}q=q->next;}p->num=num;break;case 2:printf("输入新的年级:");scanf("%d",&gra);p->grade=gra;break;case 3:printf("输入新的专业:");scanf("%s",&maj);strcpy(p->major,maj);break;case 4:printf("输入新的成绩:");scanf("%f",&score_1);p->score_1=score_1;p->aver=(p->score_1+p->score_2+p->score_3)/3;p->total=p->score_1+p->score_2+p->score_3; break;case 5:printf("输入新的成绩:");scanf("%f",&score_2);p->score_2=score_2;p->aver=(p->score_1+p->score_2+p->score_3)/3;p->total=p->score_1+p->score_2+p->score_3;break;case 6:printf("输入新的成绩:");scanf("%f",&score_3);p->score_3=score_3;p->aver=(p->score_1+p->score_2+p->score_3)/3;p->total=p->score_1+p->score_2+p->score_3;break;}printf("选择你要执行的内容:\n1、返回上一菜单\n2、返回主菜单\n3、修改另一学生的数据");loop_5: scanf("%d",&n);if(n<1||n>3){printf("输入的选择有误,请重新输入:");goto loop_5;}switch(n){case 1:goto loop;break;case 2:break;case 3:goto loop_1;break;}return(head);}void read(){struct student *p,*head;FILE *fp;if(all==0){printf("系统没有学生数据。\n");return;}if((fp=fopen("student.txt","rb"))==NULL){printf("打开文件失败。\n");exit(0);}p=(struct student*)malloc(sizeof(struct student));fread(p,sizeof(struct student),1,fp);head=p;printf("打开 student.txt 文件的学生数据。\n");printf("listnum name grade major score_1 score_2 score_3 aver total\n");while(p!=NULL){printf("student %-3d %-4s %-5d %-5s %-7.2f %-7.2f %-7.2f %-4.2f %-5.2f \n",p->num,p->name,p->grade,p->major,p->score_1,p->score_2,p->score_3,p->aver,p->total);p=p->next;}fclose(fp);}void aversort(struct student *head){int temp;float temp_1;char temp_2[10];struct student *p,*q,*i;FILE *fp;p=head;while(p->next!=NULL){q=p;i=p->next;while(i!=NULL){if(i->aver>q->aver)q=i;i=i->next;}if(q!=p){temp=p->num;p->num=q->num;q->num=temp;strcpy(temp_2,p->name);strcpy(p->name,q->name);strcpy(q->name,temp_2);temp=p->grade;p->grade=q->grade;q->grade=temp;strcpy(temp_2,p->major);strcpy(p->major,q->major);strcpy(q->major,temp_2);temp_1=p->score_1;p->score_1=q->score_1;q->score_1=temp_1;temp_1=p->score_2;p->score_2=q->score_2;q->score_2=temp_1;temp_1=p->score_3;p->score_3=q->score_3;q->score_3=temp_1;temp_1=p->aver;p->aver=q->aver;q->aver=temp_1;temp_1=p->total;p->total=q->total;q->total=temp_1;}p=p->next;}if((fp=fopen("student_1.txt","wb+"))==NULL){printf("打开 student_1.txt 文件失败\n");exit(0);}p=head;while(p!=NULL){fwrite(p,sizeof(struct student),1,fp);p=p->next;}p=head;rewind(fp);printf("读出由平均成绩排序出来的文件 student_1.txt。\n");printf("listnum name grade major score_1 score_2 score_3 aver total\n");while(p!=NULL){fread(p,sizeof(struct student),1,fp);printf("student %-3d %-4s %-5d %-5s %-7.2f %-7.2f %-7.2f %-4.2f %-5.2f \n",p->num,p->name,p->grade,p->major,p->score_1,p->score_2,p->score_3,p->aver,p->total);p=p->next;}fclose(fp);}void totalsort(struct student *head){int temp;float temp_1;char temp_2[10];struct student *p,*q,*i;FILE *fp;p=head;while(p->next!=NULL){q=p;i=p->next;while(i!=NULL){if(i->total>q->total)q=i;i=i->next;}if(q!=p){temp=p->num;p->num=q->num;q->num=temp;strcpy(temp_2,p->name);strcpy(p->name,q->name);strcpy(q->name,temp_2);temp=p->grade;p->grade=q->grade;q->grade=temp;strcpy(temp_2,p->major);strcpy(p->major,q->major);strcpy(q->major,temp_2);temp_1=p->score_1;p->score_1=q->score_1;q->score_1=temp_1;temp_1=p->score_2;p->score_2=q->score_2;q->score_2=temp_1;temp_1=p->score_3;p->score_3=q->score_3;q->score_3=temp_1;temp_1=p->aver;p->aver=q->aver;q->aver=temp_1;temp_1=p->total;p->total=q->total;q->total=temp_1;}p=p->next;}if((fp=fopen("student_1.txt","wb+"))==NULL){printf("打开 student_1.txt 文件失败\n");exit(0);}p=head;while(p!=NULL){fwrite(p,sizeof(struct student),1,fp);p=p->next;}p=head;rewind(fp);printf("读出由平均成绩排序出来的文件 student_1.txt。\n");printf("listnum name grade major score_1 score_2 score_3 aver total\n");while(p!=NULL){fread(p,sizeof(struct student),1
temp=head;
while(temp!
if(temp->num==p->num)
temp=temp->next;
n=1;
printf("该链表一共有节点个数%d。
\n",n);
printf("输入将数据插入第几个节点后面。
if(m<0||m>n)
printf("输入有误,请重新输入。
if(m==0)
p->next=head;
while((m-1)!
m--;
p->next=q->next;
q->next=p;
struct student *alter()
int m,num,gra,n;
char maj[10],name[10];
float score_1,score_2,score_3;
printf("输入修改学生数据的姓名:
scanf("%s",&name);
while(strcmp(name,p->name)!
if(p==NULL)
printf("没有该学生。
printf("请选择修改学生的具体数据:
\n1、学号;2、年级;3、专业;\n4、成绩
1;5、成绩 2;6、成绩 3:
if(m<1||m>6)
printf("输入新的学号:
");loop_2:
while(q!
if(q->num==num)
goto loop_2;
p->num=num;break;
printf("输入新的年级:
");scanf("%d",&gra);p->grade=gra;break;
printf("输入新的专业:
");scanf("%s",&maj);strcpy(p->major,maj);break;
printf("输入新的成绩:
");scanf("%f",&score_1);p->score_1=score_1;
p->aver=(p-
>score_1+p->score_2+p->score_3)/3;
p->total=p-
>score_1+p->score_2+p->score_3; break;
");scanf("%f",&score_2);p->score_2=score_2;
>score_1+p->score_2+p->score_3;break;
");scanf("%f",&score_3);p->score_3=score_3;
printf("选择你要执行的内容:
\n1、返回上一菜单\n2、返回主菜单\n3、修改另一学生
的数据");
if(n<1||n>3)
goto loop;break;
goto loop_1;break;
void read()
struct student *p,*head;
printf("系统没有学生数据。
return;
printf("打开 student.txt 文件的学生数据。
printf("listnum name grade major score_1 score_2 score_3 aver total\n");
printf("student %-3d %-4s %-5d %-5s %-7.2f %-7.2f %-7.2f %-4.2f %-5.2f \n",
p->num,p->name,p->grade,p->major,p->score_1,p->score_2,p->score_3,p-
>aver,p->total);
void aversort(struct student *head)
int temp;
float temp_1;
char temp_2[10];
struct student *p,*q,*i;
i=p->next;
while(i!
if(i->aver>q->aver)
q=i;
i=i->next;
if(q!
=p)
temp=p->num;p->num=q->num;q->num=temp;
strcpy(temp_2,p->name);strcpy(p->name,q->name);strcpy(q->name,temp_2);
temp=p->grade;p->grade=q->grade;q->grade=temp;
strcpy(temp_2,p->major);strcpy(p->major,q->major);strcpy(q->major,temp_2);
temp_1=p->score_1;p->score_1=q->score_1;q->score_1=temp_1;
temp_1=p->score_2;p->score_2=q->score_2;q->score_2=temp_1;
temp_1=p->score_3;p->score_3=q->score_3;q->score_3=temp_1;
temp_1=p->aver;p->aver=q->aver;q->aver=temp_1;
temp_1=p->total;p->total=q->total;q->total=temp_1;
if((fp=fopen("student_1.txt","wb+"))==NULL)
printf("打开 student_1.txt 文件失败\n");
rewind(fp);
printf("读出由平均成绩排序出来的文件 student_1.txt。
void totalsort(struct student *head)
if(i->total>q->total)
fread(p,sizeof(struct student),1
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1