c语言课程设计报告书--学生成绩管理_第1页
c语言课程设计报告书--学生成绩管理_第2页
c语言课程设计报告书--学生成绩管理_第3页
c语言课程设计报告书--学生成绩管理_第4页
c语言课程设计报告书--学生成绩管理_第5页
已阅读5页,还剩10页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、.C 语言程序设计报告课题:学生成绩管理 时间:2010/7/15一、需求分析任务要求:自学C语言中有关链表及外部文件的内容,设计出学生成绩管理。具体要求如下:1.主要功能:(1)能按学期、按班级完成对学生成绩的录入、修改(2)能按班级统计学生的成绩,求学生的总分及平均分,并能根据学生的平均成绩进行排序(3)能查询学生成绩,不及格科目及学生名单(4)能按班级输出学生的成绩单系统功能需求分析:1、定义一个结构体类型,成员包括学期、班级、各科成绩、建立链表,定义该结构体类型的指针,用于指向各结点; 2、分别建立具有添输入、修改、查询、总分及平均分、排序等功能的子函数,完成相应功能,对程序实现模块化

2、。二、概要设计系统总体设计框架: 对程序进行模块化,建立输入、修改、查询、查找和显示功能的子函数,各子函数中运用链表存储数据。系统功能模块图:输入学生信息成绩管理成绩查询添加信息修改记录求总分平均分排序输出结果成绩查询不及格科目学生名单三、详细设计主要功能模块的算法设计思路如下:1、输入信息函数(1)定义指向结构体变量的指针;(2)移动指针,找到插入结点;(3)在要插入的结点输入信息;(4)返回头指针。2、修改信息(1)定义指向结构体变量的指针;(2)用指针检验链表中是否有记录,若没记录,出现报错,然后要求重新输入;(3)根据要修改的编号查找对应结点;(4)修改信息;(5)修改成功。3、排序函

3、数(1)定义所要排序的班级和链表的头指针为形参;(2)调用排序函数,把班级和链表的头指针赋给形参;(3)在子函数中进行排序;(4)输出排序结果。4、显示学生成绩信息(void Disp(Link l))(1)选择想要查询的项目(学生各科成绩、不及格科目、班级成员);(2)用指针检验是否有记录;(3)若无记录,输出提示信息,返回主函数;若有记录,移动指针,依次输出记录;5、查询班级成绩信息(void Find(Link l))(1)选择所要查询的班级;(2)输入班级:(3)在链表中寻找相应结点;(4)输出结点信息。以上各个函数的流程图如下: 主函数定义程序所需变量调用CREAT函数创建一个信息链

4、表并返回指针继续进行操作1、修改信息2、统计成绩并排序3、查找信息4、输出成绩输入所需修改学生的姓名输入班级查询分数查询科目查询班级输入班级序号调用add并赋值给P->sum查找班内成员调用average函数输入姓名并查找学生输出不及格学生的姓名及成绩输入班级序号并输出班级成员的名字逐个输出他们的各科成绩并赋值给P->ave输出排序前的学生成绩调用sort 进行排序输出排序后的学生成绩是否继续操作子函数排序:f!=p->classp=p->nextf=r->classf=s->next->class&&s->next交换结构体内各

5、成员的值求和:int sumi=p->classyesnosum=p->scor_1+ p->scor_2+ p->scor_3return(sum)求平均数:float aveint sum sum=add(I,P)ave=sum/3.0return (ave)四、主要源程序代码#include <stdio.h>#include <malloc.h>#include <string.h>#define NULL 0#define LEN sizeof (struct student)#define PRINT printf(&qu

6、ot;=main menu=n")#define PRIN printf("Please chose the number:n")#define PRI printf("Sorry,the number you chose is error,please chose againn")struct student *定义一个结构体* int term; *学期* int class; *班级* char name20; *姓名* int score_1; *科目一* int score_2; *科目二* int score_3; *科目三* fl

7、oat ave; *平均分* int sum; *总分* struct student *next;int n;struct student *creat(void) *创建信息链表* struct student *head; struct student *p1,*p2; n=0; p1=p2=(struct student *)malloc(LEN); printf("Please input the student information:n"); printf("Term Class Name Score_1 Score_2 Score_3n"

8、); scanf("%d%d%s%d%d%d",&p1->term,&p1->class,p1->name,&p1->score_1,&p1->score_2,&p1->score_3); head=NULL; while(p1->term!=0) n=n+1; if(n=1) head=p1; else p2->next=p1; p2=p1; p1=(struct student *) malloc(LEN); scanf("%d%d%s%d%d%d",&p

9、1->term,&p1->class,p1->name,&p1->score_1,&p1->score_2,&p1->score_3); p2->next=NULL; return(head);void sort(struct student *p,int f) *排序(形参为链表的头指针和想要排序的班级)* int a,b,c,e; float d; char z20; struct student *r,*s; while(f!=p->class) *判断是否是想要排序的班级* p=p->next; fo

10、r(r=p;f=p->class&&r;r=r->next) for(s=p;s->next&&f=s->next->class;s=s->next) if(s->ave<(s->next)->ave) *交换结构体各个成员* d=s->ave; s->ave=s->next->ave; s->next->ave=d; a=s->score_1; s->score_1=s->next->score_1; s->next->score

11、_1=a; b=s->score_2; s->score_2=s->next->score_2; s->next->score_2=b; c=s->score_3; s->score_3=s->next->score_3; s->next->score_3=c; e=s->sum; s->sum=s->next->sum; s->next->sum=e; strcpy(z,s->name); strcpy(s->name,s->next->name); strcp

12、y(s->next->name,z); int add(int i,struct student *p) *求和(形参为想要求和的班级和链表的头指针)* int sum; if(i=p->class) sum=p->score_1+p->score_2+p->score_3; return(sum);float average(int i,struct student *p) *求平均分(形参为想要求和的班级和链表的头指针)* float ave; int sum; sum=add(i,p); *调用add函数求和* ave=sum/3.0; return(

13、ave);void main() *主函数* int i,m; struct student *p,*q; printf("=Now begin to set up=n"); p=creat(); *调用creat函数,并创建一个信息链表* q=p; do PRINT; printf(" 1:correct the student informationn"); *修改学生信息* printf(" 2:calculate the students' score and then sortn"); *统计学生成绩并排序* pri

14、ntf(" 3:search the students' informationn"); *查找学生信息* printf(" 4:output the score of studentn"); *输出学生成绩* PRIN; do scanf("%d",&i); if(i!=1&&i!=2&&i!=3&&i!=4) PRI; *报错功能* while(i!=1&&i!=2&&i!=3&&i!=4); if(i=1) char

15、x20; printf("Please input the name of student you want to correct:"); do scanf("%s",x); *输入你要修改学生成绩的姓名* for(p=q;p!=NULL;p=p->next) if(strcmp(x, p->name)=0) *查找学生* printf("Now,please input the new score of the student:n"); *输入新的成绩* printf("Score_1 Score_2 Scor

16、e_3n"); scanf("%d%d%d",&p->score_1,&p->score_2,&p->score_3); printf("Information correct succeedn"); printf("Now,%s's score is %-6d%-6d%-6dn",x,p->score_1,p->score_2,p->score_3); break; if(p=NULL) printf("Can't find the st

17、udent,please input again:"); * 报错功能* while(p=NULL); p=q; if(i=2) int j; printf("Please input which class you want to count:"); scanf("%d",&j); *输入你想要统计的班级* printf("The score information of %d class is:n",j); printf("Name Score_1 Score_2 Score_3 Average Sum

18、n"); for(p=q;p!=NULL;p=p->next) p->sum=add(j,p); * 调用函数add并赋值给结构体* p->ave=average(j,p); *调用函数average并赋值给结构体* p=q; printf("Before sorted,the student score is:n"); for(p=q;p!=NULL;p=p->next) if(j=p->class) printf("%-9s%-9d%-9d%-9d%-9.2f%-9dn",p->name,p->sc

19、ore_1,p->score_2,p->score_3,p->ave,p->sum); *输出排序前的学生成绩* p=q; sort(p,j); *调用函数sort* printf("After sorted,the student score is:n"); for(p=q;p!=NULL;p=p->next) if(j=p->class) printf("%-9s%-9d%-9d%-9d%-9.2f%-9dn",p->name,p->score_1,p->score_2,p->score_3

20、,p->ave,p->sum); *输出排序后的成绩* p=q; if(i=3) int a; char y20; PRINT; printf(" 1:search the score of studentn"); *查询学生的各科分数* printf(" 2:search the score of fail lessonn"); *查询不及格科目* printf(" 3:search the name of studentn"); *查询每个班级的成员* printf("What's do you wa

21、nt to do?"); PRIN; scanf("%d",&a); *输入你想要执行的操作的序号* if(a=1) printf("Please input the student name:"); do scanf("%s",y); *输入你想要查询的学生的姓名* for(p=q;p!=NULL;p=p->next) if(strcmp(y,p->name)=0) *查找学生* printf("%s's score is %d %d %dn",p->name,p-&g

22、t;score_1,p->score_2,p->score_3);break; *输出学生的成绩* if(p=NULL) printf("Can't find the student,please input again:"); *报错功能* while(p=NULL); p=q; else if(a=2) for(p=q;p!=NULL;p=p->next) if(p->score_1<60) printf("%s's lesson 1 is failed and the score is %dn",p-&

23、gt;name,p->score_1); if(p->score_2<60) printf("%s's lesson 2 is failed and the score is %dn",p->name,p->score_2); if(p->score_3<60) printf("%s's lesson 3 is failed and the score is %dn",p->name,p->score_3); p=q; else if(a=3) int c; printf("

24、Please input the number of class:n"); scanf("%d",&c); *输入你想要输出成绩的班级* printf("The %d class have these student:n",c); for(p=q;p!=NULL;p=p->next) if(c=p->class) printf("%-10s",p->name); printf("n"); p=q; if(i=4) int b; printf("Please input which class:n"); *输入你想要输出成绩的班级* scanf("%d",&b); printf("Now,the score of the student of %d class is:n",b

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论