学生成绩管理系统C语言课程设计.docx
- 文档编号:12332421
- 上传时间:2023-04-18
- 格式:DOCX
- 页数:30
- 大小:23.40KB
学生成绩管理系统C语言课程设计.docx
《学生成绩管理系统C语言课程设计.docx》由会员分享,可在线阅读,更多相关《学生成绩管理系统C语言课程设计.docx(30页珍藏版)》请在冰豆网上搜索。
学生成绩管理系统C语言课程设计
××××学院课程设计报告
课程名称:
学院:
专业班级:
姓名:
学号:
指导教师 :
完成时间:
报告成绩 :
评阅意见:
评阅老师:
评阅时间:
1 / 21
《学生成绩管理系统》C 语言课程设计
一、 设计要求
1) 收集资料,全面分析课题,分解问题,形成中体编程思路;
2) 深入分析各个小问题,编写个部分程序模块;
3) 对于设计中用到的关键函数,要联系实际 问题进行具体介绍;
4) 上机调试,确保程序能正确运行;
二、 设计目的:
1) 通过设计,了解 C 语言的实际运用,加强对 C 语言的重视;
2) 通过设计,强化 C 语言的基本运用及 C 语句的准确掌握;
3) 通过设计,掌握设计软件一般方法,了解软件设计的一般思路;
4) 通过设计,锻炼撰写报告的水平。
三、 课题分析:
编写一个《学生成绩管理系统》的 C 程序,包括以下功能:
1) 学号段查询功能;
2) 输入功能;
3) 添加功能、修改功能;
4) 成绩处理功能等
5) 可实现数据输入、数据显示、数据插入、数据访问、数据保留、数据更新等存储
功能,以及各学科平均分、最高分、最低分的提取等数据处理功能。
该程序运行相对只能
化,可通过学号比较来插入数据、根据姓名查找数据以及更新数据。
其操作简单,查找方
便,修改迅速,普遍适合学校学生成绩管理,可大大减少人工管理的工作量,提高工作效
率。
四、 定义数据结构及相关解释:
1) 在《学生成绩管理系统》中,各模块功能系统之间构成的数据结构关系为非线性数
据结构的树结构。
2) 树结构:
每一个结点只有一个前件,称为父结点。
没有前件的结点只有一个,称为
树的根结点,简称树的根。
在《学生成绩管理系统》中的数据结构图中“图书馆管理程序”
为根;在树结构中,每一个结点都可以有多个后件,他们都称为该结点的子结点,没有后
件的结点称为叶子。
例如,在《学生成绩管理系统》中的数据结构图中“查看数据”通
过比较学号来插入数据”、 通过姓名查找查看数据”、 通过姓名查找来更新数据”、 保
2 / 21
留数据”以及求各学科的“平均分、最高分、最低分”为“学生成绩管理系统”的子结点,
也是该树结构的叶子。
五、 软件的模块划分:
根据对《学生成绩管理系统》功能分析的情况,可将《学生成绩管理系统》做如下模
块划分:
1)main( )主函数 --- 学生成绩管理系统程序主函数;
2)print( )打印函数 --- 设置学生成绩管理系统界面;
3)cin( )数据输入函数 --- 数据多格式输入;
4)cindata( )其他数据继续输入函数;
5)lookdata( )查看数据函数 --- 查看已保存的数据;
6)insert( )插入数据的函数 --- 通过比较学号来插入数据;
7)find( )查看数据的函数 --- 通过姓名查找查看数据;
8)update( )更新数据的函数 --- 姓名查找来更新数据;
9)save( )保留数据函数 --- 储存处理后的数据;
10) caverage();求各学生语文平均分、最高和最低分成绩的函数;
11) maverage();求各学生数学平均分、最高和最低分成绩的函数;
12) eaverage();求各学生英语平均分、最高和最低分成绩的函数;
13) comaverage();求各学生计算机平均分、最高和最低分成绩的函数
注:
(2)—(13)为自定义功能函数,通过 main()主函数调用实现其功能。
六、 程序流程设计:
根据《学生成绩管理系统》功能分析绘制流程图:
3 / 21
开始passwords初始界面用户信息
输入其他数据
插入数据
功能选择
查找查看数据
查找更新数据
保留数据
显示或打印数据
求学生语文平均分
求学生数学平均分
求学生英语平均分
求学生计算机平均分
空操作
主程序流程图, 学生成
绩管理系统》操作流程。
返回
其他数据输入姓名学号性别成绩
语文
数学
英语
计算机
继续输入
选择 返回
其他数据输入过程
注:
其他功能的流程图可参照“其他数据输入”的流程图绘制。
4 / 21
七、 各功能模块编写内容详细情况及调试:
1) 数据类型的定义。
在定义数据类型时,由于学生成绩管理信息需要由不同类型的数据反映出来。
如:
姓
名、性别都需要用 char 型数据,而学号和成绩则需要用 int 型数据,并且每位同学的以
上信息都需要一次性输入,所以采用结构体类型定义。
如:
typedef struct student/*定义结构体*/
{
char name[MAX];-------------------- 定义 char 型姓名
int num[MAX];-------------------- 定义 int 型学号
char sex[MAX];-------------------- 定义 char 型性别
int chinese;-------------------- 定义 int 型语文成绩
int mathematic;-------------------- 定义 int 型数学成绩
int english;-------------------- 定义 int 型英语成绩
int computer;-------------------- 定义 int 型计算机成绩
struct student *next; -------------------- 结构体指针
}stu;
说明:
在定义结构体类型和变量时,可采用先定义结构体类型再定义结构提变量,也
可同时定义结构体类型和变量,还可以直接定义结构提变量。
上例中的定义方式为同时定
义结构体的类型和变量。
结构体定义的格式如下:
struct[结构体名]
{
类型标识符成员名;
};
2) 函数的命名和库函数的使用。
A. 函数命名是遵循标识符的命名规则,并且要尽量做到顾名思义的效果。
如:
lookdata( )为查看数据函数。
B. 库函数使用时要提前声明( #include
者已自定义的函数中,否则编译出错。
C. 函数调用时要注意形参和实参数据类型的对应。
5 / 21
3) 函数结构和功能实现。
A. 数据输入函数“cin( )”
B. 查看数据函数“lookdata( )”
C. 插入数据的函数“insert( )”
D. 查看数据的函数“find( )”
E. 更新数据的函数“update( )”
F. 保留数据函数“save( )”
注:
以上的六个功能函数为《学生成绩管理系统》的输入、读取、修改等主要功能函
数,其中主要运用字符串比较,定义指针变量,输入输出等多种函数和操作实现其对外界
输入内容进行处理功能以及防止出错的备份功能。
G. 管理系统中的各个模块函数的功能实现基本都依靠与以上三中函数类似的编辑方
法编写。
主要通过以下结构实现对应功能。
for 循环结构 —— 对使用者输入内容与内部资料内容进行核对。
switch 选择结构 —— 对使用者所选择的项目进行判断并调用对应的函数。
if-else 选择结构 —— 配合 for 循环核对内容的正确与否选择对应的操作。
while 、do-while 循环结构 —— 条件判断并进行对应的操作。
H. 具体功能函数源程序的编辑内容见后文的《图书馆管理系统》源程序。
八、 源程序内容及调试结果。
1) 源程序(原始密码是 123456):
#include"stdio.h"
#include"stddef.h"
#include"stddef.h"
#include"string.h"
#define MAX 10
typedef struct student{/*定义结构体*/
char name[MAX];/*姓名*/
int num[MAX];/* 学号*/
char sex[MAX];/*性别*/
6 / 21
int chinese;/*语文*/
int mathematic;/* 数学*/
int english;/*英语*/
int computer;/*计算机*/
struct student *next;/*结构体指针*/
}stu;
stu *head;/*头指针*/
void print()/*显示或打印函数*/
{
system("cls");
printf("\t\t\tScore Manage System\n");/*成绩管理系统*/
printf("<1>Enter Record\t");/*输入数据*/
printf("<2>Display\t");/*显示*/
printf("<3>Insert\t");/*插入数据*/
printf("<4>Quest\t");/*访问数据*/
printf("<5>Update\t");/*以前数据*/
printf("<6>Save\t");/*保留数据*/
printf("<7>Fresh\t");/*更新数据*/
printf("<8>Chinese Average\t");/*语文平均成绩*/
printf("<9>Math Average\t");/*数学平均成绩*/
printf("<10>English Average\t");/*英语平均成绩*/
printf("<11>Computer Average\t");/*计算机平均成绩*/
printf("<12>Quit\t\n");/*退出*/
}
void cin(stu *p1)/*输入相关数据的函数*/
{ printf("Enter name:
\n");
scanf("%s",&p1->name);
printf("Enter num:
\n");
scanf("%d",&p1->num);
printf("Enter sex:
\n");
scanf("%s",&p1->sex);
printf("Enter score:
\n");
printf("Enter chinese:
\n");
scanf("%d",&p1->chinese);
printf("Enter math:
\n");
scanf("%d",&p1->mathematic);
7 / 21
printf("Enter English:
\n");
scanf("%d",&p1->english);
printf("Enter Computer:
\n");
scanf("%d",&p1->computer);
}
stu *cindata()/*其他数据是否继续输入的函数*/
{ stu *p1,*p2;
int i=1;
char ch;
p1=(stu *)malloc(sizeof(stu));
head=p1;
while(i)
{
cin(p1);
printf("Do you Want to Continue?
yes or no");/*是否继续输入数据*/
ch=getchar();
ch=getchar();
if(ch=='n'||ch=='N')
{ i=0;
p1->next=NULL;
}
else
{ p2=p1;
p1=(stu *)malloc(sizeof(stu));
p2->next=p1;
}
}
return(p1->next);
}
stu *lookdata(stu *p1)/*查看数据的函数*/
{
while(p1!
=NULL)
{ printf("Num:
%d\t",p1->num);
printf("Name:
%s\t",p1->name);
printf("Sex:
%s\t",p1->sex);
printf("\n");
8 / 21
printf("Chinese:
%d\t",p1->chinese);
printf("Math:
%d\t",p1->mathematic);
printf("English:
%d\t",p1->english);
printf("Computer:
%d\t",p1->computer);
printf("\n");
p1=p1->next;
}
return p1;
}
void insert()/*通过比较学号来插入数据的函数*/
{ stu *p1,*p3,*p2;
char ch;
p1=head;
p3=(stu *)malloc(sizeof(stu));
p3->next=NULL;
if(head==NULL){ head=p3; return;}
cin(p3);
while(p1!
=NULL&&(p1->num
{ p2=p1;p1=p1->next;}
if(p2==head) {p3->next=head; head=p3; return;}
p3->next=p1;
p2->next=p3;
}
find(stu *p2)/*通过姓名查找查看数据的函数*/
{ char name[20];
int b=0;
printf("Enter the name of the student you want to find:
"); /*通过姓名查看*/
scanf("%s",name);
while(p2!
=NULL)
{if(strcmp(name,p2->name)==0)
{
printf("The data you want has be found\n");
printf(" Name:
%s\t",p2->name);
9 / 21
printf("Num:
%d\t",p2->num);
printf("sex%s\t",p2->sex);
printf("\n");
printf("Chinese:
%d\t",p2->chinese);
printf("Math:
%d\t",p2->mathematic);
printf("English:
%d\t",p2->english);
printf("Computer:
%d\t",p2->computer);
printf("\n");
b=1;
}
else if(b==0)
printf("sorry not find data!
");
p2=p2->next;
}
if(b==1)
{
print();
printf("Find one\n");}
else
{print();
printf("Not find\n");
}
}
void caverage()/*求各学生语文平均分、最高和最低分成绩的函数*/
{ stu *p1;
int i;
float max=0.0,min=200.0;
float sum=0.0,aver=0;
p1=head;
if(p1==NULL)
printf("not data!
");
else
{for(i=0;p1!
=NULL;i++,p1=p1->next)
sum+=p1->chinese;
aver=sum/i;
10 / 21
p1=head;
for(i=0;p1!
=NULL;i++,p1=p1->next)
{if(max
max=p1->chinese;
}
p1=head;
for(i=0;p1!
=NULL;i++,p1=p1->next)
if(min>p1->chinese)
min=p1->chinese;
}
printf("Chinese Average:
%f",aver);
printf("Chinese Max:
%f",max);
printf("Chinese Min:
%f",min);
}
void maverage()/*求各学生数学平均分、最高和最低分成绩的函数*/
{ stu *p1;
int i;
float max=0.0,min=200.0;
float sum=0.0,aver=0;
p1=head;
if(p1==NULL)
printf("not data!
");
else
{for(i=0;p1!
=NULL;i++,p1=p1->next)
sum+=p1->mathematic;
aver=sum/i;
p1=head;
for(i=0;p1!
=NULL;i++,p1=p1->next)
{if(max
max=p1->mathematic;
}
p1=head;
for(i=0;p1!
=NULL;i++,p1=p1->next)
if(min>p1->mathematic)
min=p1->mathematic;
}
11 / 21
printf("Mathe Average:
%f",aver);
printf("Mathe Max:
%f",max);
printf("Mathe Min:
%f",min);
}
void eaverage()/*求各学生英语平均分、最高和最低分成绩的函数*/
{ stu *p1;
int i;
float max=0.0,min=200.0;
float sum=0.0,aver=0;
p1=head;
if(p1==NULL)
printf("not data!
");
else
{for(i=0;p1!
=NULL;i++,p1=p1->next)
sum+=p1->english;
aver=sum/i;
p1=head;
for(i=0;p1!
=NULL;i++,p1=p1->next)
{if(max
max=p1->english;
}
p1=head;
for(i=0;p1!
=NULL;i++,p1=p1->next)
if(min>p1->english)
min=p1->english;
}
printf("English Average:
%f",aver);
printf("English Max:
%f",max);
printf("English Min:
%f",min);
}
void comaverage()/*求各学生计算机平均分、最高和最低分成绩的函数*/
{ stu *p1;
int i;
float max=0.0,min=200.0;
12 / 21
float sum=0.0,aver=0;
p1=head;
if(p1==NULL)
printf("not data!
");
else
{for(i=0;p1!
=NULL;i++,p1=p1->next)
sum+=p1->computer;
aver=sum/i;
p1=head;
for(i=0;p1!
=NULL;i++,p1=p1->next)
{if(max
max=p1->computer;
}
p1=head;
for(i=0;p1!
=NULL;i++,p1=p1->next)
if(min>p1->computer)
min=p1->computer;
}
printf("Computer Average:
%f",aver);
printf("Computer Max:
%f",max);
printf("Computer Min:
%f",min);
}
update(stu *p2)/*通过姓名查找来更新数据*/
{
char name[10];/*p2 为指向结构体 struct student 的指针*/
int b=0;
printf("Enter The Name");/*输入姓名*/
scanf("%s",name);
while(p2!
=NULL)
{if(strcmp(name,p2->name)==0)
{
printf("Find you data\n");
scanf("Name:
%s",p2->name);
scanf("Num:
%s",p2->num);
scanf("Sex:
%s",p2->sex);
13 / 21
scanf("Chinese:
%d",p2->chinese);
scanf("Math:
%d",p2->mathematic);
scanf("english:
%d",p2->english);
scanf("Computer:
%d",p2->computer);
printf("Success!
");
b=1;}
else if(b==0)
printf("Sorry not Find data!
");
p2=p2->next;}
if(b==0)
{print();
printf("Sorry not Find data!
");
}
else
{
print();
printf("Finish!
");
}
}
save(stu *p2)/*保留数据函数*/
{
FILE *fp;
char ];
printf("Enter ");/*输入文件名*/
scanf("%s",file);
fp=fopen(file,"w");
while(p2!
=NULL)
{
fprintf(fp,"%s",p2->name);
fprintf(fp,"%s",p2->num);
fprintf(fp,"%s",p2->sex);
fprintf(fp,"%d",p2->chinese);
fprintf(fp,"%d",p2->mathematic);
fprintf(fp,"%d",p2->english);
fprintf(fp,"%d",p2->computer);
p2=p2->next;
14 / 21
}
fclose(fp);
}
char password[7]="123456";/*定义初始密码*/
void main()/*主函数*/
{ int choice;
stu *p2;
char s[8];
int flag=0,i;/*标志项*/
int n=3;
do{ printf("Enter password:
\n");
scanf("%s",s);
if(!
strcmp(s,password))/*进行密码匹配验证*/
{ printf("PASS\n\n\n");
flag=1;
break;
}
else{
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 学生 成绩管理系统 语言 课程设计