C语言学生成绩管理系统课程设计报告.docx
- 文档编号:8738522
- 上传时间:2023-02-01
- 格式:DOCX
- 页数:26
- 大小:65.55KB
C语言学生成绩管理系统课程设计报告.docx
《C语言学生成绩管理系统课程设计报告.docx》由会员分享,可在线阅读,更多相关《C语言学生成绩管理系统课程设计报告.docx(26页珍藏版)》请在冰豆网上搜索。
C语言学生成绩管理系统课程设计报告
西安郵電大學
C语言课程设计报告
题目:
学生成绩管理系统
院系名称:
计算机学院
专业名称:
计算机科学与技术
班级:
计科1102
学生姓名:
冯佳新
学号(8位):
04111067
指导教师:
李川
设计起止时间:
2012年6月6日~2012年6月15日
一.设计目的
1.强化上机动手能力,在理论和实践的基础上进一步巩固《C语言程序设计》课程学习的内容,掌握工程化软件设计的基本方法
2.学会将知识应用于实际的方法,提高分析和解决问题的能力,增加综合能力
3.为后续各门计算机课程的学习打下坚实基础
二.设计内容
1、密码登录;
2、通过键盘输入学生信息,包括学生学号、姓名、成绩;
3、将输入的信息保存到指定文件中;
4、从文件中读取学生信息;
5、显示全部学生信息;
6、按学生总分进行降序排序;
7、删除学生信息;
8、查找学生信息,可以通过学号查找,也可以通过姓名查找;
9、统计学生信息,统计出最高分和学生人数;
10、退出系统;
三.概要设计
1.功能模块图;
统计
学生
信息
2.各个模块详细的功能描述。
1、密码登录:
进入系统前需输入密码口令,此处的密码分为管理员登录密码“abcde”,学生登录密码“12345”;
2、输入信息:
输入学生信息,包括:
学号、姓名、成绩;
3、显示信息:
显示输入的信息或者经过处理后的信息
4、查找信息:
查找学生信息,可以按学号查找,也可以按姓名查找;
5、修改信息:
修改学生的任何信息;
6、删除信息:
通过查找学生姓名删除该学生信息;
7、排序信息:
将输入的学生信息排序,按总分成绩降序排列;
8、统计信息:
统计出所有信息中的最高分成绩的学生的信息和学生人数。
四.详细设计
1.功能函数的调用关系图
按2键退出系统
2.各功能函数的数据流程图
1、主函数模块
密码正确
2、输入模块
返回
2、输出与排序模块
结束
3、删除与修改信息模块
否
4、统计信息模块
结束
4、查找信息模块
结束
3.重点设计及编码
此程序的重点是既能把学生信息保存到文件中,又能保存到磁盘中,方便实用与读取,代码如下:
structstudent*creat(structstudent*p)//创建链表
{
structstudent*p1=NULL;
p1=(structstudent*)malloc(sizeof(structstudent));
p->next=p1;
p1->next=NULL;
printf("请输入要添加的学生的信息\n");
printf("学号:
");scanf("%s",p1->num);
printf("姓名:
");scanf("%s",p1->name);
printf("数学成绩:
");scanf("%d",&p1->scorem);
printf("英语成绩:
");scanf("%d",&p1->scoree);
printf("C成绩:
");scanf("%d",&p1->scorec);
p1->sum=0;
p1->sum=p1->scorem+p1->scorec+p1->scoree;
printf("总分:
%d",p1->sum);
returnp1;
}
voidsave1(structstudent*p)//将链表从内存保存到文件中
{
FILE*fp;
if((fp=fopen("d:
\\学生成绩管理系统.txt","ab+"))==NULL)
printf("创建失败!
\n");
while(p!
=NULL)
{
fwrite(p,sizeof(structstudent),1,fp);
p=p->next;
}
fclose(fp);
printf("保存成功!
\n");
}
voidsave2(structstudent*p)//将以变动的链表信息存入到文件中
{
FILE*fp;
if((fp=fopen("d:
\\学生成绩管理系统.txt","wb"))==NULL)
printf("创建失败!
\n");
while(p!
=NULL)
{
fwrite(p,sizeof(structstudent),1,fp);
p=p->next;
}
fclose(fp);
}
structstudent*read()//把文件中的数据读到链表中
{
FILE*fp;
structstudent*head=NULL,*p1=NULL,*p2=NULL;
if((fp=fopen("d:
\\学生成绩管理系统.txt","rb+"))==NULL)
{
printf("读取时,文件打开失败!
\n");
returnNULL;
}
head=p1=(structstudent*)malloc(sizeof(structstudent));
while(fp!
=NULL)
{
if(fread(p1,sizeof(structstudent),1,fp)!
=1)break;
p1->next=(structstudent*)malloc(sizeof(structstudent));
p2=p1;
p1=p1->next;
}
p2->next=NULL;
fclose(fp);
returnhead;
}
五.测试数据及运行结果
1.正常测试数据和运行结果
1.按总分排序
2.删除某个学生信息
3.查找学生信息
2.异常测试数据及运行
1.删除信息出现异常
2.修改学生信息出现异常
六.调试情况,设计技巧及体会
1、对自己设计进行评价
1)不够细心,开始的时候出现很多错误
2)没有写登录函数
3)写的过于简短,且大部分都是书上照抄的
2.调试上得到的体会:
在最后的调试过程中,发现有时候系统报错,指出了错误所在的具体位置,可是检查的时候发现该位置并未出错,这样的错误首先要查找前后几行,如果还未检查出错误,那就很有可能在该函数的首部或是主函数的调用语句中出现错误。
发现该部分并未出现语法错误,即编译不报错,程序运行后,有时候会出现意想不到的结果,会在想不到的地方跳出程序,甚至不知道程序的什么地方就跳出了,用在不同的地方加不必要的printf语句!
以检查是否运行到printf语句。
3.设计上得到的体会:
在初步设计时要明确要使用的数据结构和类型,明确设计的基本思想,清楚所写程序的逻辑结构和执行顺序,在调试时才能在出现问题时及时的找到问题的所在.在完成了初步的设计并调试完成后,要进一步优化程序的结构,使程序更简洁,执行效率更高.
总之,第一次完成比较正式的程序,在开始的时候遇到了不少问题,包括怎么排序,怎么添加,怎么查找,怎么删除等一系列问题,但我并没有慌张,而是由一个问题入手,最后将它们一一攻破,顺利而又艰难的完成了这次任务;通过这次实习,我的编程能力得到了很大的提高,算法思路也比以前清晰多了,基本上掌握了C语言的课程内容,虽然只有为期两周的实习,但是我的C语言还是得到了进一步的提高。
不过要想使自己的水平提高,还有待练习。
虽然实习结束了,但是以后在工作中可能会经常使用,这次的实习的确是一个很好的锻炼机会,它一定会使我受益终身的!
七.参考文献
《C语言程序设计》(第二版),
《数据结构(C语言)》清华大学出版社
八.附录:
源代码(电子版)
#include
#include
#include
structstudent
{
charnum[9];
charname[9];
intscorem;
intscoree;
intscorec;
intsum;
structstudent*next;
};
structstudent*creat(structstudent*p)//创建链表
{
structstudent*p1=NULL;
p1=(structstudent*)malloc(sizeof(structstudent));
p->next=p1;
p1->next=NULL;
printf("请输入要添加的学生的信息\n");
printf("学号:
");scanf("%s",p1->num);
printf("姓名:
");scanf("%s",p1->name);
printf("数学成绩:
");scanf("%d",&p1->scorem);
printf("英语成绩:
");scanf("%d",&p1->scoree);
printf("C成绩:
");scanf("%d",&p1->scorec);
p1->sum=0;
p1->sum=p1->scorem+p1->scorec+p1->scoree;
printf("总分:
%d",p1->sum);
returnp1;
}
voidsave1(structstudent*p)//将链表从内存保存到文件中
{
FILE*fp;
if((fp=fopen("d:
\\学生成绩管理系统.txt","ab+"))==NULL)
printf("创建失败!
\n");
while(p!
=NULL)
{
fwrite(p,sizeof(structstudent),1,fp);
p=p->next;
}
fclose(fp);
printf("保存成功!
\n");
}
voidsave2(structstudent*p)//将以变动的链表信息存入到文件中
{
FILE*fp;
if((fp=fopen("d:
\\学生成绩管理系统.txt","wb"))==NULL)
printf("创建失败!
\n");
while(p!
=NULL)
{
fwrite(p,sizeof(structstudent),1,fp);
p=p->next;
}
fclose(fp);
}
structstudent*read()//把文件中的数据读到链表中
{
FILE*fp;
structstudent*head=NULL,*p1=NULL,*p2=NULL;
if((fp=fopen("d:
\\学生成绩管理系统.txt","rb+"))==NULL)
{
printf("读取时,文件打开失败!
\n");
returnNULL;
}
head=p1=(structstudent*)malloc(sizeof(structstudent));
while(fp!
=NULL)
{
if(fread(p1,sizeof(structstudent),1,fp)!
=1)break;
p1->next=(structstudent*)malloc(sizeof(structstudent));
p2=p1;
p1=p1->next;
}
p2->next=NULL;
fclose(fp);
returnhead;
}
structstudent*input()//添加函数
{
charch;
structstudent*p=NULL,*head=NULL;
head=p=(structstudent*)malloc(sizeof(structstudent));
p->next=NULL;
printf("请输入要添加的学生的信息\n");
printf("学号:
");scanf("%s",p->num);
printf("姓名:
");scanf("%s",p->name);
printf("数学成绩:
");scanf("%d",&p->scorem);
printf("英语成绩:
");scanf("%d",&p->scoree);
printf("C成绩:
");scanf("%d",&p->scorec);
p->sum=0;
p->sum=p->scorem+p->scorec+p->scoree;
printf("总分:
%d",p->sum);
for(;;)
{
printf("\n是否继续输入学生信息?
(y/n):
\n");
getchar();
ch=getchar();
if(ch=='y'||ch=='Y')
p=creat(p);
elseif(ch=='n'||ch=='N')
{
save1(head);
break;
}
else
printf("您的输入有误,请重新输入,");
}
returnp->next;
}
structstudent*output()//输出函数,查看全部学生信息
{
structstudent*p;
p=read();
if(read==NULL)
exit
(1);
printf("\n*************************STUDENT***********************\n");
printf("-------------------------------------------------------\n");
printf("|学号|姓名|数学|英语|C语言|总分|\n");
printf("-------------------------------------------------------\n");
while(p!
=NULL)
{
p->sum=0;
p->sum=p->scorem+p->scoree+p->scorec;
printf("|%4s|%-4s|%3d|%3d|%3d|%3d|\n",p->num,
p->name,p->scorem,p->scoree,p->scorec,p->sum);
printf("-------------------------------------------------------\n");
p=p->next;
}
returnp;
}
structstudent*search()//查找函数
{
intn;
chara[9],b[9];
structstudent*p=NULL,*head=NULL;
printf("请您选择要查找的方式:
1按姓名2按学号\n");
scanf("%d",&n);
if(n==1)
{
printf("请输入您要查找的学生的姓名:
\n");
scanf("%s",a);
p=head=read();
while(p!
=NULL)
{
if(p==NULL)
{
printf("对不起,没有您要找的人。
\n");
}
if(strcmp(p->name,a)==0)
{
printf("\n*************************STUDENT***********************\n");
printf("-------------------------------------------------------\n");
printf("|学号|姓名|数学|英语|C语言|总分|\n");
printf("-------------------------------------------------------\n");
printf("|%4s|%-4s|%3d|%3d|%3d|%3d|\n",p->num,
p->name,p->scorem,p->scoree,p->scorec,p->sum);
printf("-------------------------------------------------------\n");
break;
}
p=p->next;
}
}
if(n==2)
{
printf("请输入您要查找的学生的学号:
\n");
scanf("%s",b);
p=head=read();
while(p!
=NULL)
{
if(p==NULL)
{
printf("对不起,没有您要找的人。
\n");
}
if(strcmp(p->num,b)==0)
{
printf("\n*************************STUDENT***********************\n");
printf("-------------------------------------------------------\n");
printf("|学号|姓名|数学|英语|C语言|总分|\n");
printf("-------------------------------------------------------\n");
printf("|%4s|%-4s|%3d|%3d|%3d|%3d|\n",p->num,
p->name,p->scorem,p->scoree,p->scorec,p->sum);
printf("-------------------------------------------------------\n");
break;
}
p=p->next;
}
}
returnhead;
}
structstudent*dele()//删除函数
{
structstudent*p1=NULL,*p2=NULL,*head=NULL;
chara[9];
output();
printf("请输入需要删除信息的人的姓名:
\n");
scanf("%s",a);
p1=head=read();
if(head==NULL)
{
printf("对不起,暂时没有信息,无法删除。
\n");
}
while(head!
=NULL)
{
if(strcmp(a,head->name)!
=0&&p1->next!
=NULL)
{
p2=head;
head=head->next;
if(head==NULL)break;
}
if(strcmp(a,head->name)==0&&p1==head)
{
p1=head->next;
}
if(strcmp(a,head->name)==0)
{
p2->next=head->next;
save2(p1);
printf("该学生的信息删除成功!
");
break;
}
}
if(head==NULL)
printf("对不起,没有该学生的信息。
\n");
returnhead;
}
structstudent*change()//修改函数
{
inta;
charx[9];
structstudent*p=NULL,*head=NULL,*q=NULL;
output();
p=head=read();
printf("请输入要修改的人的姓名:
\n");
scanf("%s",x);
if(p==NULL)
{
printf("没有这个人!
\n");
exit
(1);
}
while(p!
=NULL)
{
if(strcmp(p->name,x)==0)
{
q=p;
break;
}
p=p->next;
}
if(p!
=NULL)
{
printf("请选择修改的内容:
\n");
printf("1.姓名\n");
printf("2.学号\n");
printf("3.数学成绩\n");
printf("4.英语成绩\n");
printf("5.C成绩\n");
do
{
scanf("%d",&a);
if(a<0||a>6)
printf("您输入的数字有误,请重新输入:
\n");
}while(a<=0||a>=6);
switch(a)
{
case1:
printf("请输入更改后的姓名:
\n");scanf("%s",p->name);break;
case2:
printf("请输入更改后的学号:
\n");scanf("%s",p->num);break;
case3:
printf("请输入更改后的数学成绩:
\n");scanf("%d",&p->scorem);break;
case4:
printf("请输入更改后的英语成绩:
\n");scanf("%d",&p->scoree);break;
case5:
printf("请输入更改后的C成绩:
\n");scanf("%d",&p->scorec);break;
}
p->sum=0;
p->sum=p->scorem+p->scoree+p->scorec;
printf("更改后的总分:
%d",p->sum);
save2(head);
ou
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 语言 学生 成绩管理系统 课程设计 报告