c语言程序的设计_学生成绩管理系统方案_第1页
c语言程序的设计_学生成绩管理系统方案_第2页
c语言程序的设计_学生成绩管理系统方案_第3页
c语言程序的设计_学生成绩管理系统方案_第4页
已阅读5页,还剩20页未读 继续免费阅读

下载本文档

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

文档简介

1、.实验题目 : 学生成绩管理系统一、实验目的1. 熟悉 c 语言的编译连接和运行过程。2. 掌握 c 语言的数据类型,熟悉整型、实型、字符型变量的定义方式及如何给它们赋值。3. 掌握 if 语句及 switch 语句的运用方法及嵌套应用方法。4. 掌握实现循环结构的三种语句 while 、 do-while. 、for 的使用。5. 掌握函数的定义方法和调用方法。6. 能够采用模块化思想调试程序。二实验内容1. 编写程序并进行调试运行。2. 输入学生资料 , 并保存于文件。每个学生包含信息如:姓名、学号、性别、物理成绩、数学成绩、英语成绩、计算机成绩。3. 对已存入的学生信息进行更新操作 ,

2、包括更新学生信息信息、 删除某个学生信息和修改学生信息。4. 通过按学生姓名的方式查询学生信息。5. 输入某学生各门成绩进行统计。6 对学生物理成绩排序。7. 最后输出学生信息,供需要时打印。二、 需求分析1. 该程序可用于对学生的基本信息的存储、更新、查询、输出、统计、排序等操作。2. 其中更新功能包括:添加信息、删除信息、修改信息、可根据需要添加一个或多个学生 信息 , 也可对个别学生信息进行适当的删除或修改。以便随时更新学生信息。3. 程序中设计的查询功能可根据需要从若干数据中查询某信息,四、概要设计1、方案设计对系统进行分析,给出结构图分析:系统要求实现许多的功能, 因此遵循结构化程序

3、设计思想来进行本系统的设计自顶向下、 逐步细化,将系统设计任务分解出许多子功能模块进行设计结构图如下:.下载可编辑 .学生成绩管显输插查更统成物数英计保输示入入看新计绩理学语算存出数数数数数成排成成成机数数据据据据据绩序绩绩绩成据据绩更删修物数英计物新除改理学语算理数数数总总总机成据据据分分分平绩和和和均排平平平分序.下载可编辑 .五功能模块的说明1输入初始学生信息:其中包括学生姓名,学号,性别,物理数学 英语 计算机成绩 等相关信息;可用函数 cin(stu *p1) 来实现此操作。2查询模块:可用 stu *lookdata(stu *p1)来实现。找到就输出此学生全部信息包括学生物理 数

4、学 英语 计算机的成绩 。3插入模块:可用 insert() 来实现。其中通过学号的大小比较的,并且以此来排序。4输出学生的信息及成绩:通过学生的姓名来查看学生的语文数学 英语 计算机的有关成绩,同时也可以分别通过paverage() maverage() eaverage()comaverage() 来输出物理 数学 英语 计算机等成绩的平均分最高分 最低分。5退出系统:可以用一个函数来实现, 首先将信息保存在文件中, 释放动态创建的内存空间,再退出次程序。流程图如下六 调试情况及运行结果1、对自己设计进行评价,指出合理和不足之处,提出改进的方案。此次实践课编写的是一个应用程序, 相对于以前

5、我们见到的程序, 它要大得多,于是就按课本上的例子编了超市管理系统, 先把界面弄好然后再添加各模块,而且各模块也出现了不少问题, 在同学们和老师的帮助下,我很有耐心的一次又一次的进行修改, 最后运行的结果基本上达到了预期的目的。可结果还不是太理想。由于时间很短, 在选题报告中设想到的好多功能都没有实现。 已有的那些功能虽已能基本上满足管理者和消费者的需要, 但如果还有更多的功能程序就会更加完美。如:进入系统时没有设制密码,保护性不够强;在输入商品号时没有出错提示,如果商品号输入负值2、在设计过程中的感受。本次 C 语言的实习课让我对 C 语言的学习又有了更深入的了解,也让我更深刻地领悟到了 “

6、实践出真理” 这个道理,在上机实践过程中学到的知识远远超过了在课堂上十几周学到的, 学校组织的这次实习让我们这些实践知识匮乏的大学生增添了许多社会经验, 为我们将来走上工作岗位其了不小的铺垫作用。本次实习中遇到了很多以前没有遇到过的问题, 也曾想过要放弃, 但看到那些同学都在那认真的写程序, 给了我继续的信心。 在同学的帮助下, 我顺利的结束了本次实习, 让我知道原来凭借自己努力取得的成功会让自己这么欣慰,也让我知道了友谊和团结的重要性。七参考文献C 语言程序设计王曙燕曹锰科学出版社八。附录:.下载可编辑 .#include <stdio.h>#include <stddef

7、.h>#include <stddef.h>#include <string.h>#include <stdlib.h>#include <conio.h>#define MAX 10int sum=10;typedef struct student/*定义结构体 */char nameMAX;/*姓名 */int num;/*学号 */char sexMAX;/*性别 */float physic;/*语文 */float mathematic;/*数学 */float english;/*英语 */float computer;/*计算

8、机 */struct student *next;/*结构体指针 */stu;stu *head;/* 读取信息 */int read_message() FILE *fp; stu *p; int i=0;if(fp=fopen("student_manage.txt","rb")=NULL) printf("nn*暂时还没有任何信息,输入密码进入主菜单选择基本信息录入!*n");return 0;while(feof(fp)!=1) fread(head,sizeof(stu),1,fp); if(p->num=0) bre

9、ak;else i+;fclose(fp);return(i);.下载可编辑 ./*显示或打印函数*/void print()printf("ttt Score Manage Systemn");/*成绩管理系统 */printf("ttt成绩管理系统 n");printf("<1>EnterRecord :输入数据n");/*输入数据 */printf("<2>Display :显示或打印n");/*显示 */printf("<3>find:查找数据n");

10、/*访问数据 */printf("<4>Renew_message:更新模块n");/*更新模块 */printf("<5>Save:保存数据n");printf("<6>sort_physic:成绩排名n");/*物理成绩排名 */printf("<7>Count:数据统计n");/*数据统计 */printf("<8>Physic Average:物理平均成绩n");/*物理平均成绩 */printf("<9>

11、Math Average:数学平均成绩n");/*数学平均成绩 */printf("<10>English Average:英语平均成绩n");/*英语平均成绩 */printf("<11>Computer Average:计算机平均成绩n");/*计算机平均成绩 */printf("<12>Quit:退出tn");/*退出 */*输入相关数据函数*/void cin(stu *p1)printf("n Enter name:n");scanf("%s&quo

12、t;,&p1->name);.下载可编辑 .printf("Enter num:n");scanf("%d",&p1->num);printf("Enter sex:n");scanf("%s",&p1->sex);printf("Enter scoren");printf("Enter physic:n");scanf("%f",&p1->physic);printf("Enter mat

13、hematic:n");scanf("%f",&p1->mathematic);printf("Enter english:n");scanf("%f",&p1->english);printf("Enter computer:n");scanf("%f",&p1->computer);/*其他数据是否输入函数*/stu *cindata() stu *p1,*p2; int i=1; char ch; p1=(stu*)malloc(size

14、of(stu); head=p1;while(i) cin(p1);printf("Do you want to continue?Yes or no:n"); fflush(stdin);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!=N

15、ULL)printf("Name:%st",p1->name);printf("Num:%dt",p1->num);printf("Sex:%st",p1->sex);printf("n");printf("Physic:%ft",p1->physic);printf("Math:%ft",p1->mathematic);printf("English:%ft",p1->english);printf("Com

16、puter:%ft",p1->computer);printf("n");p1=p1->next;return p1;/*通过比较学号来插入数据的函数*/void insert() stu *p1,*p3,*p2; p1=head; p3=(stu*)malloc(sizeof(stu);p3->next=NULL;if(head=NULL) head=p3;return; cin(p3);while(p1!=NULL&&(p1->num<p3->num) p2=p1;p1=p1->next; if(p2=

17、head) p3->next=head; head=p3;return; p3->next=p1;p2->next=p3;.下载可编辑 ./*通过姓名来查找的函数*/void find(stu *p2) char name20; int b=0;printf("Enter the name of the sutdent you want to find:"); scanf("%s",name);while(p2!=NULL)if(strcmp(name,p2->name)=0) printf(" The data you

18、 want has be find "); printf("Name:%st",p2->name); printf("Num:%dt",p2->num); printf("Sex:%st",p2->sex); printf("n"); printf("Physic%ft",p2->physic); printf("Math%ft",p2->mathematic); printf("English%ft",p2->

19、;english); printf("Computer%ft",p2->computer); printf("n");b=1;else if(b=0)printf("sorry not find data!");p2=p2->next;if(b=1)print();printf("Find onen");elseprint();printf("Not findn");.下载可编辑 ./*求各学生物理平均成绩*/void paverage() stu *p1; int i;float

20、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;p1=p1->next) sum+=p1->physic; aver=sum/i;p1=head;for(i=0;p1!=NULL;i+,p1=p1->next)if(max<p1->physic) max=p1->physic;p1=head;for(i=0;p1!=NULL;i+,p1=p1->next)if(min>p

21、1->physic)min=p1->physic;printf("Physic Average:%f ",aver);printf("Physic Max:%f",max);printf("Physic Min:%f",max);/* 求各学生数学平均分最高和最低分成绩的函数*/.下载可编辑 .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

22、data!");elsefor (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<p1->mathematic) max=p1->mathematic;p1=head;for(i=0;p1!=NULL;i+,p1=p1->next)if(min>p1->mathematic)min=p1->mathematic;printf("Math Avera

23、ge:%f",aver);printf("Math Max:%f",max);printf("Math 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!");elsefor(i=0;p1!=NULL;i+,p1=p1->next)sum+=p1->

24、english;aver=sum/i;p1=head;for(i=0;p1!=NULL;i+,p1=p1->next) if(max<p1->english) 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 M

25、in:%f",min);/* 求各学生计算机平均成绩最高和最低分 */void comaverage() 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!");elsefor(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<

26、p1->computer)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);/* 统计物理平均和总分*/void aver_sum_physic() stu *p1; int

27、i;float sum=0,aver; p1=head; if(p1=NULL)printf("not data!"); else for(i=0;p1!=NULL;i+,p1=p1->next) sum+=p1->physic; aver=sum/i;printf("Physic Average:%f",aver);printf("Physic Sum:%f",sum);/* 统计数学平均和总分*/void aver_sum_mathematic() stu *p1; int i;.下载可编辑 .float sum=0,

28、aver;p1=head;if(p1=NULL)printf("not data!");else for(i=0;p1!=NULL;i+,p1=p1->next) sum+=p1->mathematic; aver=sum/i;printf("Mathematic Average:%f",aver);printf("Mathematic Sum:%f",sum);/* 统计英语平均和总分*/void aver_sum_english() stu *p1; int i;float sum=0,aver; p1=head; i

29、f(p1=NULL)printf("not data!");else for(i=0;p1!=NULL;i+,p1=p1->next) sum+=p1->english; aver=sum/i;printf("English Average:%f",aver);printf("English Sum:%f",sum);/* 统计计算机平均和总分*/void aver_sum_computer() stu *p1; int i;float sum=0,aver; p1=head;if(p1=NULL) printf(&quo

30、t;not data!");else.下载可编辑 . for(i=0;p1!=NULL;i+,p1=p1->next) sum+=p1->computer; aver=sum/i;printf("Computer Average:%f",aver);printf("Computer Sum:%f",sum);/* 统计模块 */void count() int choice;doprintf(" *统计学生平均分和总分 *n");printf("<1>:物理平均和总分 n");pr

31、intf("<2>:数学平均和总分 n");printf("<3>:英语平均和总分 n");printf("<4>:计算机平均和总分 n");printf("<0>返回主菜单 :n");printf("请选择 (04):n");scanf("%d",&choice);switch(choice) case 1:aver_sum_physic();break;case 2:aver_sum_mathematic();bre

32、ak;case 3:aver_sum_english();break;case 4:aver_sum_computer();break;case 0:break;while(choice!=0);/* 物理成绩排序*/* 库存排行 */sort_physic()int i=1,j=1;.下载可编辑 .float min;stu *newh,*newp,*tp1,*tp2,*p;newp=newh=NULL;tp1=tp2=NULL;p=head;doi+;p=p->next;while(p->next);while(head!=NULL)p=head;tp1=tp2=p;min=p

33、->physic;while(p->next!=NULL)if(p->next->physic<min)min=p->next->physic;tp1=p;tp2=p->next;p=p->next;if(newh=NULL)newp=newh=tp2;elsenewp->next=tp2;newp=tp2;if(tp2=head)head=tp2->next;elsetp1->next=tp2->next;tp2->next=NULL;head=newh;p=head;for(j=1;j<=i;j+)i

34、f(p!=NULL).下载可编辑 .printf("n物理成绩排行 n");printf("-");printf("n排名姓名性别学号物理成绩 n");printf("n%18d %6s %8s %11d %10fn",j,p->name,p->sex,p->num,p->physic);p=p->next;else break;printf("n按任意键返回n");getch();/* 删除相关数据*/shanchu() int num; stu *p,*p0;

35、p=head; cin(p);printf(" 请输入要删除的学号 :"); scanf("%d",&num); head=p->next;free(p);return 1;p0=p->next;while(p0!=NULL)if(p0->num=num)p->next=p;free(p0);return 1;p=p0;p0=p0->next;return 0;.下载可编辑 ./* 修改模块 */void revise_message(stu *h)int choice,revise_num,flag;stu *p;

36、p=head;doprintf("n输入要修改的学生的学号:");scanf("%d",&revise_num);while(p->num!=revise_num)p=p->next;/*查找 */if(p->num=revise_num)printf("n-学生信息 -n");n");printf("学号 - 姓名 - 性别 - 物理成绩 - 数学成绩 - 英语成绩 - 计算机成绩 n");printf("%8s%4d%8s%8f%8f%8f%8fn",p-

37、>name,p->num,p->sex,p->physic,p->mathematic,p->english,p->computer);printf("n您要修改哪一项 ?n");printf("n1、姓名 n");printf("n2、学号 n");printf("n3、性别 n");printf("n4物理成绩 n");printf("n5、数学成绩 n");printf("n6、英语成绩 n");printf

38、("n7、计算机成绩 n");printf("n请选择( 1-7 ) :");scanf("%d",&choice);switch(choice).下载可编辑 .case 1:printf("n输入修改后的学生姓名:");scanf("%s",p->name);break;case 2:printf("n输入修改后的学生学号:");scanf("%d",p->num);break;case 3:printf("n输入修改后的性

39、别:");scanf("%s",&p->sex);case 4:printf("n输入修改后的物理成绩:");scanf("%f",&p->physic);case 5:printf("n输入修改后的数学成绩:");scanf("%f",&p->mathematic);case 6:printf("n输入修改后的英语成绩:");scanf("%f",&p->english);break;ca

40、se 7:printf("n输入修改后的计算机成绩:");scanf("%f",&p->computer);break;printf("-n");printf("学号 - 姓名 - 性别 - 物理成绩 - 数学成绩 - 英语成绩 - 计算机成绩 n");printf("%8s%4d%8s%8f%8f%8f%8fn",p->name,p->num,p->sex,p->physic,p->mathematic,p->english,p->com

41、puter);break;if(p->next=NULL)printf("n该学生不存在!");printf("nn 要继续吗 ?(y/n)"); choice=getch();if(choice='y')|(choice='Y').下载可编辑 .printf("n继续 !n");flag=1;else flag=0;while(flag=1);printf("n按任意键返回主菜单!n");/* 更新模块 */void renew_message() int choice;do

42、 printf("nn*更新学生信息 *nn");printf("1.添加信息 nn");printf("2.删除信息 nn");printf("3.修改信息 nn");printf("4.返回主菜单 nn");printf("请选择( 03) :");scanf("%d",&choice);switch(choice) case 1: insert();break; case 2: shanchu();break;case 3: revise_m

43、essage(head);break;case 0:;break;while(choice!=0);/* 保留数据函数*/void save(stu *p2) FILE *fp;char file10;printf("Enter file name");scanf("%s",file);fp=fopen(file,"w");while(p2!=NULL)fprintf(fp,"%s",p2->name);fprintf(fp,"%d",p2->num);fprintf(fp,&quo

44、t;%s",p2->sex);fprintf(fp,"%f",p2->physic);fprintf(fp,"%f",p2->mathematic);.下载可编辑 .fprintf(fp,"%f",p2->english);fprintf(fp,"%f",p2->computer);p2=p2->next;fclose(fp);/*主函数 */char password7="123456"void main()/*初始化 */char choices

45、;stu *p2;char s8;int flag=0,i;/*标志项 */int n=3;sum=read_message();doprintf("Enter password:n");scanf("%s",s);if(!strcmp(s,password) printf("PASSnnn");flag=1;break;elseprintf(" Error Enter againn");n-;while(n>0);if(!flag) printf("You have Enter 3 times!"); exit(0);.下载可编辑 .printf(&quo

温馨提示

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

最新文档

评论

0/150

提交评论