学生管理.docx
- 文档编号:7381220
- 上传时间:2023-01-23
- 格式:DOCX
- 页数:12
- 大小:18.09KB
学生管理.docx
《学生管理.docx》由会员分享,可在线阅读,更多相关《学生管理.docx(12页珍藏版)》请在冰豆网上搜索。
学生管理
学生管理系统
C语言程序设计
设计题目
1.学生管理系统
功能:
(1)数据录入功能:
对B.TXT进行数据录入,只录入每个学生的学号、课程编号、课程名称、学分、平时成绩、实验成绩、卷面成绩共7个数据。
综合成绩、学分由程序根据条件自动运算。
综合成绩的计算:
如果本课程的实验成绩为-1,则表示无实验,综合成绩=平时成绩*30%+卷面成绩*70%;如果实验成绩不为-1,表示本课程有实验,综合成绩=平时成绩*15%+实验成绩*15%+卷面成绩*70%。
实得学分的计算:
采用等级学分制。
综合成绩在90-100之间,应得学分=学分*100%综合成绩在80-90之间,应得学分=学分*80%
综合成绩在70-80之间,应得学分=学分*75%综合成绩在60-70之间,应得学分=学分*60%
综合成绩在60以下,应得学分=学分*0%
(2)查询功能:
分为学生基本情况查询和成绩查询两种
(3)删除功能:
当在A.TXT中删除一个学生时,自动地在B.TXT中删除此人所有信息。
(4)排序功能:
能实现选择按综合成绩或实得学分升序或降序排序并显示数据。
(6)至少采用文本菜单界面(如果能采用图形菜单界面更好)
(7)必须要用到链表,能将生成的文件存储于外部存储器上,并且从外部存储器上可以读写该文件的功能。
创新要求:
在基本要求达到后,可进行创新设计。
本程序在CODEBLOCK8.02进行程序编辑,整合与调试。
与TC类似。
若有不符,自行调试。
代码如下:
#include
#include
#include
#include
#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=='Y'||ch=='y')
{
p1=(structstudent*)malloc(LEN);
printf("请输入第%d个学生的信息:
\n",n+1);
printf("\n请输入学号:
");
scanf("%s",p1->xuehao);
printf("\n请输入课程编号:
");
scanf("%s",p1->kechengbianhao);
printf("\n请输入课程名称:
");
scanf("%s",p1->kechengmingcheng);
printf("\n请输入学分:
");
scanf("%f",&p1->xuefen);
printf("\n请输入平时成绩:
");
scanf("%f",&p1->pingshichengji);
printf("\n请输入实验成绩:
");
scanf("%f",&p1->shiyanchengji);
printf("\n请输入卷面成绩:
");
scanf("%f",&p1->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
p1->zonghechengji=p1->pingshichengji*3/20+p1->shiyanchengji*3/20+p1->juanmianchengji*7/10;}
{
if(p1->zonghechengji>90)
p1->yingdexuefen=p1->xuefen*1;
else
if(p1->zonghechengji>80)
p1->yingdexuefen=p1->xuefen*8/10;
else
if(p1->zonghechengji>70)
p1->yingdexuefen=p1->xuefen*3/4;
else
if(p1->zonghechengji>60)
p1->yingdexuefen=p1->xuefen*3/5;
else
p1->yingdexuefen=0;}
getchar();
printf("\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)
{
printf("can'topenthisfile!
\n");
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))
{
printf("closefail!
\n");
exit(0);
}
printf("录入的学生信息已经保存在“B.txt”文件中\n");
}
voidprint1(structstudent*head)//.................................输出函数........................................//
{
structstudent*p;
p=head;
printf("学号课程编号课程名称学分平时成绩实验成绩卷面成绩\n");
do
{
printf("%s%s%s%f%f%f%f\n",p->number,p->kechengbianhao,p->kechengmingcheng,p->xuefen,p->pingshichengji,p->shiyanchengji,p->juanmianchengji);
p=p->next;
}while(p!
=NULL);
}
structstudent*fileopen_c()//................................从文件中读出信息...............................//
{
FILE*fp;
structstudent*p1,*p2;
intii=0;
if((fp=fopen("B.txt","r"))==NULL)
{
printf("找不到文件!
\n");
exit(0);
}
head=NULL;
while(!
feof(fp))
{
p1=(structstudent*)malloc(sizeof(structstudent));
fscanf(fp,"%s%s%s%f%f%f%f%f%f",p1->xuehao,p1->kechengbianhao,p1->kechengmingcheng,&p1->xuefen,&p1->pingshichengji,&p1->shiyanchengji,&p1->juanmianchengji,&p1->yingdexuefen,&p1->zonghechengji);
ii=ii+1;
if(ii==1)
head=p1;
else
p2->next=p1;
p2=p1;
}
p2->next=NULL;
return(head);
}
structStudent*Sort(structStudent*head,intcourse)//............................排序函数..........................//
{
structstudent*p,*q,*t;
intl;
charnumber[20];
charkechengbianhao[20];
charkechengmingcheng[20];
floatxuefen;
floatpingshichengji;
floatshiyanchengji;
floatjuanmianchengji;
structstudent*next;
system("cls");
printf("\n");
printf("\n");
printf("\n");
printf("\n");
printf("欢迎访问学生成绩排名系统\n");
printf("\n");
printf("1.平时成绩升序\n");
printf("2.平时成绩降序\n");
printf("3.实验成绩升序\n");
printf("4.实验成绩降序\n");
printf("\n\n\n请根据操作项对应的数字进行选择:
");
scanf("%d",&l);
course=1;
switch(course)
{
case1:
for(p=head;p;p=p->next)//*****平时成绩升序*******//
t=p;
for(q=head;q;q=q->next)
if(t->pingshichengji>=q->pingshichengji)
{
pingshichengji=t->pingshichengji;
juanmianchengji=t->juanmianchengji;
shiyanchengji=t->shiyanchengji;
xuefen=t->xuefen;
t->pingshichengji=q->pingshichengji;
t->juanmianchengji=q->juanmianchengji;
t->shiyanchengji=q->shiyanchengji;
t->xuefen=q->xuefen;
q->pingshichengji=pingshichengji;
q->juanmianchengji=juanmianchengji;
q->shiyanchengji=shiyanchengji;
q->xuefen=xuefen;
strcpy(number,t->number);
strcpy(t->number,q->number);
strcpy(q->number,number);
strcpy(kechengbianhao,t->kechengbianhao);
strcpy(t->kechengbianhao,q->kechengbianhao);
strcpy(q->kechengbianhao,kechengbianhao);
strcpy(kechengmingcheng,t->kechengmingcheng);
strcpy(t->kechengmingcheng,q->kechengmingcheng);
strcpy(q->kechengmingcheng,kechengmingcheng);
t=q;
}
print1(head);
break;
case2:
for(p=head;p;p=p->next)//*****平时成绩降序*******//
t=p;
for(q=head;q
next)
if(t->pingshichengji<=q->pingshichengji)
{
pingshichengji=t->pingshichengji;
juanmianchengji=t->juanmianchengji;
shiyanchengji=t->shiyanchengji;
xuefen=t->xuefen;
t->pingshichengji=q->pingshichengji;
t->juanmianchengji=q->juanmianchengji;
t->shiyanchengji=q->shiyanchengji;
t->xuefen=q->xuefen;
q->pingshichengji=pingshichengji;
q->juanmianchengji=juanmianchengji;
q->shiyanchengji=shiyanchengji;
q->xuefen=xuefen;
strcpy(number,t->number);
strcpy(t->number,q->number);
strcpy(q->number,number);
strcpy(kechengbianhao,t->kechengbianhao);
strcpy(t->kechengbianhao,q->kechengbianhao);
strcpy(q->kechengbianhao,kechengbianhao);
strcpy(kechengmingcheng,t->kechengmingcheng);
strcpy(t->kechengmingcheng,q->kechengmingcheng);
strcpy(q->kechengmingcheng,kechengmingcheng);
t=q;
}
print1(head);
break;
case3:
for(p=head;p;p=p->next)//*****实验成绩升序*******//
t=p;
for(q=head;q
next)
if(t->shiyanchengji>=q->shiyanchengji)
{
shiyanchengji=t->shiyanchengji;
juanmianchengji=t->juanmianchengji;
pingshichengji=t->pingshichengji;
xuefen=t->xuefen;
t->shiyanchengji=q->shiyanchengji;
t->juanmianchengji=q->juanmianchengji;
t->pingshichengji=q->pingshichengji;
t->xuefen=q->xuefen;
q->shiyanchengji=shiyanchengji;
q->juanmianchengji=juanmianchengji;
q->pingshichengji=pingshichengji;
q->xuefen=xuefen;
strcpy(number,t->number);
strcpy(t->number,q->number);
strcpy(q->number,number);
strcpy(kechengbianhao,t->kechengbianhao);
strcpy(t->kechengbianhao,q->kechengbianhao);
strcpy(q->kechengbianhao,kechengbianhao);
strcpy(kechengmingcheng,t->kechengmingcheng);
strcpy(t->kechengmingcheng,q->kechengmingcheng);
strcpy(q->kechengmingcheng,kechengmingcheng);
t=q;
}
print1(head);
break;
case4:
for(p=head;p;p=p->next)//*****实验成绩降序*******//
t=p;
for(q=head;q
next)
if(t->shiyanchengji<=q->shiyanchengji)
{
shiyanchengji=t->shiyanchengji;
juanmianchengji=t->juanmianchengji;
pingshichengji=t->pingshichengji;
xuefen=t->xuefen;
t->shiyanchengji=q->shiyanchengji;
t->juanmianchengji=q->juanmianchengji;
t->pingshichengji=q->pingshichengji;
t->xuefen=q->xuefen;
q->shiyanchengji=shiyanchengji;
q->juanmianchengji=juanmianchengji;
q->pingshichengji=pingshichengji;
q->xuefen=xuefen;
strcpy(number,t->number);
strcpy(t->number,q->number);
strcpy(q->number,number);
strcpy(kechengbianhao,t->kechengbianhao);
strcpy(t->kechengbianhao,q->kechengbianhao);
strcpy(q->kechengbianhao,kechengbianhao);
strcpy(kechengmingcheng,t->kechengmingcheng);
strcpy(t->kechengmingcheng,q->kechengmingcheng);
strcpy(q->kechengmingcheng,kechengmingcheng);
t=q;
}
print1(head);
break;
}
returnhead;
}
structstudent*insert(structstudent*head)//..............................插入函数.................................//
{
structstudent*p1,*p2,*p3;
intsize=sizeof(structstudent);
charch='Y';
while(ch=='Y'||ch=='y')
{
p3=(structstudent*)malloc(size);
p1=p3;
printf("输入要插入的学生的信息:
\n");
printf("\n请输入学号:
");
scanf("%s",p3->xuehao);
printf("\n请输入课程编号:
");
scanf("%s",p3->kechengbianhao);
printf("\n请输入课程名称:
");
scanf("%s",p3->kechengmingcheng);
printf("\n请输入学分:
");
scanf("%f",&p3->xuefen);
printf("\n请输入平时成绩:
");
scanf("%f",&p3->pingshichengji);
printf("\n请输入实验成绩:
");
scanf("%f",&p3->shiyanchengji);
printf("\n请输入卷面成绩:
");
scanf("%f",&p3->juanmianchengji);
{
if(p3->shiyanchengji==-1)
p3->zonghechengji=p3->pingshichengji*3/10+p3->juanmianchengji*7/10;
else
p3->zonghechengji=p3->pingshichengji*3/20+p3->shiyanchengji*3/20+p3->juanmianchengji*7/10;
}
{
if(p3->zonghechengji>90)
p3->yingdexuefen=p3->xuefen*1;
else
if(p3->zonghechengji>80)
p3->yingdexuefen=p3->xuefen*8/10;
else
if(p3->zonghechengji>70)
p3->yingdexuefen=p3->xuefen*3/4;
else
if(p3->zonghechengji>60)
p3->yingdexuefen=p3->xuefen*3/5;
else
p3->yingdexuefen=0;
}
if(head==NULL)
{
head=p1;
head->next=NULL;
}
else
{
for(p2=head;p2;p2=p2->next)
if(p2->next==NULL)
{
p2->next=p3;
p3->next=NULL;
break;
}
}
printf("是否继续插入Y/N");
getchar();
ch=getchar();
}
returnhead;
}
voidsearch(structstudent*head)//.....................
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 学生 管理