学生管理Word文件下载.docx
《学生管理Word文件下载.docx》由会员分享,可在线阅读,更多相关《学生管理Word文件下载.docx(12页珍藏版)》请在冰豆网上搜索。
本程序在CODEBLOCK8.02进行程序编辑,整合与调试。
与TC类似。
若有不符,自行调试。
代码如下:
#include<
stdio.h>
stdlib.h>
#include<
malloc.h>
string.h>
#defineNULL0
#defineLENsizeof(structstudent)
#definexuehaonumber
structstudent
{
charxuehao[20];
charkechengbianhao[20];
charkechengmingcheng[20];
floatxuefen;
floatyingdexuefen;
floatpingshichengji;
floatzonghechengji;
floatshiyanchengji;
floatjuanmianchengji;
structstudent*next;
};
intn;
structstudent*head;
structstudent*creat()//............................................创建链表...........................................//
structstudent*p1,*p2;
charch='
Y'
;
n=0;
head=NULL;
while(ch=='
||ch=='
y'
)
{
p1=(structstudent*)malloc(LEN);
printf("
请输入第%d个学生的信息:
\n"
n+1);
\n请输入学号:
"
);
scanf("
%s"
p1->
xuehao);
\n请输入课程编号:
kechengbianhao);
\n请输入课程名称:
kechengmingcheng);
\n请输入学分:
%f"
&
p1->
xuefen);
\n请输入平时成绩:
pingshichengji);
\n请输入实验成绩:
shiyanchengji);
\n请输入卷面成绩:
juanmianchengji);
n=n+1;
if(n==1)head=p1;
elsep2->
next=p1;
p2=p1;
{if(p1->
shiyanchengji==-1)
p1->
zonghechengji=p1->
pingshichengji*3/10+p1->
juanmianchengji*7/10;
else
pingshichengji*3/20+p1->
shiyanchengji*3/20+p1->
}
if(p1->
zonghechengji>
90)
yingdexuefen=p1->
xuefen*1;
80)
xuefen*8/10;
70)
xuefen*3/4;
60)
xuefen*3/5;
yingdexuefen=0;
getchar();
\n是否继续录入Y/N?
ch=getchar();
}
p2->
next=NULL;
return(head);
system("
cls"
voidsave(structstudent*head)//...........................................保存函数................................//
structstudent*p;
FILE*fp;
if((fp=fopen("
B.txt"
"
w"
))==NULL)
can'
topenthisfile!
exit(0);
for(p=head;
p;
p=p->
next)
fprintf(fp,"
%s\t%s\t%s\t%f\t%f\t%f\t%f\t%f\t%f\n"
p->
xuehao,p->
kechengbianhao,p->
kechengmingcheng,p->
xuefen,p->
pingshichengji,p->
shiyanchengji,p->
juanmianchengji,p->
yingdexuefen,p->
zonghechengji);
if(fclose(fp))
closefail!
录入的学生信息已经保存在“B.txt”文件中\n"
voidprint1(structstudent*head)//.................................输出函数........................................//
p=head;
学号课程编号课程名称学分平时成绩实验成绩卷面成绩\n"
do
%s%s%s%f%f%f%f\n"
number,p->
p=p->
next;
}while(p!
=NULL);
structstudent*fileopen_c()//................................从文件中读出信息...............................//
FILE*fp;
structstudent*p1,*p2;
intii=0;
r"
找不到文件!
while(!
feof(fp))
p1=(structstudent*)malloc(sizeof(structstudent));
fscanf(fp,"
%s%s%s%f%f%f%f%f%f"
xuehao,p1->
kechengbianhao,p1->
kechengmingcheng,&
xuefen,&
pingshichengji,&
shiyanchengji,&
juanmianchengji,&
yingdexuefen,&
ii=ii+1;
if(ii==1)
head=p1;
else
structStudent*Sort(structStudent*head,intcourse)//............................排序函数..........................//
structstudent*p,*q,*t;
intl;
charnumber[20];
欢迎访问学生成绩排名系统\n"
1.平时成绩升序\n"
2.平时成绩降序\n"
3.实验成绩升序\n"
4.实验成绩降序\n"
\n\n\n请根据操作项对应的数字进行选择:
%d"
l);
course=1;
switch(course)
case1:
for(p=head;
next)//*****平时成绩升序*******//
t=p;
for(q=head;
q;
q=q->
if(t->
pingshichengji>
=q->
pingshichengji)
pingshichengji=t->
pingshichengji;
juanmianchengji=t->
juanmianchengji;
shiyanchengji=t->
shiyanchengji;
xuefen=t->
xuefen;
t->
pingshichengji=q->
juanmianchengji=q->
shiyanchengji=q->
xuefen=q->
q->
pingshichengji=pingshichengji;
juanmianchengji=juanmianchengji;
shiyanchengji=shiyanchengji;
xuefen=xuefen;
strcpy(number,t->
number);
strcpy(t->
number,q->
strcpy(q->
number,number);
strcpy(kechengbianhao,t->
kechengbianhao,q->
kechengbianhao,kechengbianhao);
strcpy(kechengmingcheng,t->
kechengmingcheng,q->
kechengmingcheng,kechengmingcheng);
t=q;
print1(head);
break;
case2:
next)//*****平时成绩降序*******//
q<
pingshichengji<
case3:
next)//*****实验成绩升序*******//
shiyanchengji>
shiyanchengji)
case4:
next)//*****实验成绩降序*******//
shiyanchengji<
returnhead;
structstudent*insert(structstudent*head)//..............................插入函数.................................//
structstudent*p1,*p2,*p3;
intsize=sizeof(structstudent);
p3=(structstudent*)malloc(size);
p1=p3;
输入要插入的学生的信息:
p3->
p3->
if(p3->
p3->
zonghechengji=p3->
pingshichengji*3/10+p3->
pingshichengji*3/20+p3->
shiyanchengji*3/20+p3->
yingdexuefen=p3->
if(head==NULL)
head->
for(p2=head;
p2;
p2=p2->
if(p2->
next==NULL)
next=p3;
是否继续插入Y/N"
voidsearch(structstudent*head)//.....................