C语言综合设计报告_第1页
C语言综合设计报告_第2页
C语言综合设计报告_第3页
C语言综合设计报告_第4页
C语言综合设计报告_第5页
已阅读5页,还剩22页未读 继续免费阅读

下载本文档

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

文档简介

昆明理工大学C程序设计基础课程综合设计实践教学课题报告组长: 学号 * 姓名*组员: 学号 * 姓名*学号 * 姓名*学号 * 姓名*学号 * 姓名*学号 * 姓名*联系人及联系电话: * 学院: 理学院 专业班级: 电信111 指导教师: * 昆明理工大学计算中心2012年5月30日昆明理工大学计算中心程序设计基础课程综合设计实践教学课题考核表课题名称: 学生成绩管理系统 学院:理学院 专业班级:电信111学号姓名小组编号题号承担及完成的内容成绩备注小组自评教师评定9*显示函数与信息删除函数设计7*main()函数与数据结构设计1*信息录入函数与排序函数设计1*查询函数设计5*插入函数设计6*按学号排序函数与按总分排序函数设计题目及要求学生成绩管理系统用C语言编程实现学生成绩的录入、查询、添加、排序、删除等功能。教师评语教师签名:* 2012年6月10日 C程序设计课程综合设计实践教学课题报告1、 系统概述本学生成绩管理系统主要解决学生成绩的录入、查询、添加、排序、删除等问题。主要通过建立链表、插入结点、删除链表中的结点、输出链表、定义函数等方式实现预期的功能。2、数据结构设计#include #include #include #define LEN sizeof(Student)#define NULL 0typedef struct studentint num; /*定义变量:学号*/char name20; /*定义变量:姓名*/char sex2; /*定义变量:性别*/int score3; /*定义变量:成绩*/int sum; /*定义变量:总成绩*/struct student *next;Student;int n; /*定义全局变量*/Student *cin(void); /*函数声明:信息录入函数*/Student *sort_1(Student *head,int); /*函数声明:按学号排序函数*/void sort_2(Student *head); /*函数声明:按总分排序函数*/void print(Student *head); /*函数声明:显示函数*/Student *sort_all(Student *head); /*函数声明:排序函数*/void find(Student *head); /*函数声明:查询函数*/Student *add_new(Student *head); /*函数声明:插入函数*/3、模块设计设计职责分配设计内容组员main()函数与数据结构设计*信息录入函数与排序函数*按学号排序函数与按总分排序函数*查询函数*插入函数(*显示函数与信息删除函数*4运行及操作说明进入系统:根据提示从键盘录入相关信息: 5、总结和体会源程序编辑:编译:Build:运行:输入:结果:调试中遇到的主要问题及解决办法: 在程序的调试过程中,常遇到因为误删或漏写分号,或者字母大小写混乱等造成的语法错误,以及函数设计不当等造成的逻辑错误使程序编译错误。由于VC在程序编译错误时的提示信息较为冗杂且很多未能命中关键,因此,仔细逐行阅读已有代码是常用的解决问题办法,有时也以组员之间交流讨论的方式来寻求解决程序逻辑错误的方法。收获和体会:组长:本次C语言综合设计,锻炼了每一个组员的缜密思考问题并解决问题的能力,对个人的严谨行为习惯的养成有很大帮助,同时也使大家在合作中增进感情,认识到了团队合作的重要性与必要性,为今后在团队中能有更好的表现奠定了基础。组员:这次综合设计让我们有了很多提高,克服了不细心的毛病,这在我们以后的学习和工作中有很大的帮助。编程是一项周密细致的活动,对个人的严谨思考能力有很高的要求,大家的互助合作和个人的独立思考相结合,让我们在解决设计过程中遇到的问题的同时,也提高了自己的思维缜密度,获益良多。6、程序源代码/*/#include #include #include #define LEN sizeof(Student)#define NULL 0typedef struct studentint num;char name20;char sex2;int score3;int sum;struct student *next;Student;int n;Student *cin(void); Student *sort_1(Student *head,int);void sort_2(Student *head);void print(Student *head);Student *sort_all(Student *head);void find(Student *head);Student *add_new(Student *head);/*/Student *cin()/*信息录入函数*/int flag; Student *head,*p1,*p2;n=0;head=(Student *)malloc(LEN);p2=head;printf(请输入第【%d】名学生的相关信息(学号为0结束输入):n,n+1);printf(学号:); scanf(%d,&flag);while(getchar()!=n);for(;flag;) n+;p1=(Student *)malloc(LEN);p1-num=flag;printf(姓名:);scanf(%s,p1-name); printf(性别:); scanf(%s,p1-sex);printf(数学成绩:);scanf(%d,&p1-score0);printf(英语成绩:);scanf(%d,&p1-score1);printf(物理成绩:);scanf(%d,&p1-score2);p1-sum=p1-score0+p1-score1+p1-score2;p2-next=p1;p2=p1;printf(n请输入第【%d】名学生的相关信息(学号为0结束输入):n,n+1);printf(学号:);scanf(%d,&flag); p2-next=NULL;printf(nn);return head;/*/Student *sort_all(Student *head) /*排序函数*/int choose;for(;) printf(ntt+ + + + +【统计排序】 + + + + +n);printf(tt|t1.按学号排序t |n);printf(tt|t2.按总分排序t |n);printf(tt|t7.单科最高分及平均分 |n);printf(tt|t8.当前学生成绩t |n);printf(tt|t0.返回上一级菜单 |n);printf(tt+ + + + + + + + + + + + + + + +n);printf(请选择:);scanf(%d,&choose);while(getchar()!=n);switch(choose)case 1:case 2:case 3:case 4:case 5:case 6:head=sort_1(head,choose);break;case 7:print(head);sort_2(head);break;case 8:print(head);break;case 0:return head;default: printf(nn非法值!请重新输入:nn);break; /*/Student *sort_1(Student *head,int choose) /*按学号排序*/Student *p1,*p2=head-next,*pm,*px;Student mid;if (!p2) return head;for(p1=p2;p1-next!=NULL;p1=p1-next) pm=p1;for(p2=p1-next;p2!=NULL;p2=p2-next)switch (choose)case 1:if (pm-nump2-num) pm=p2;break; case 2:if (pm-sumsum) pm=p2;break; case 3:if (pm-score0score0) pm=p2;break; case 4:if (pm-score1score1) pm=p2;break; case 5:if (pm-score2score2) pm=p2;break;if (pm!=p1)mid=*pm;*pm=*p1;*p1=mid;px=pm-next;pm-next=p1-next;p1-next=px; printf(n排序后的成绩表为:n);print(head); return head;/*/void sort_2(Student *head) /*按总分排序*/Student *p=head-next;int max_1,max_2,max_3,min_1,min_2,min_3;int max_sum,min_sum;int sum_1=0,sum_2=0,sum_3=0;float aver_1,aver_2,aver_3,aver_sum;if (!p) return;max_1=min_1=p-score0;max_2=min_2=p-score1;max_3=min_3=p-score2;max_sum=min_sum=p-sum;for(;p;p=p-next) if (max_1score0) max_1=p-score0;else if (min_1p-score0) min_1=p-score0;if (max_2score1) max_2=p-score1;else if (min_2p-score1) min_2=p-score1;if (max_3score2) max_3=p-score2;else if (min_3p-score2) min_3=p-score2;if (max_sumsum) max_sum=p-sum;else if (min_sump-sum) min_sum=p-sum; sum_1+=p-score0;sum_2+=p-score1;sum_3+=p-score2; aver_1=1.0*sum_1/n;aver_2=1.0*sum_2/n;aver_3=1.0*sum_3/n;aver_sum=aver_1+aver_2+aver_3;printf(共【%d】名学生n,n); printf(总分最高分为【%d】,最低分为【%d】,平均分为【%.2f】n,max_sum,min_sum,aver_sum); /*/void find(Student *head) /*查询函数*/Student *p;int choose,fnum;char tem20;if (n=0)printf(n数据为空!n );return;for(;) printf(n选择查询方式:nn);printf(1.按学号;2.按姓名;0.不查询nn);printf(请选择:);scanf(%d,&choose);while(getchar()!=n);if (choose=1) printf(n请输入学号(输入0结束查询):);scanf(%d,&fnum);for(;fnum;)for(p=head-next;p!=NULL&p-num!=fnum;p=p-next);if (!p) printf(nn无法查询,请重新输入(输入0结束查询):);scanf(%d,&fnum);else if (p-num=fnum)printf(%d:n,p-num);printf(学号t姓名t性别t 数学成绩 英语成绩 物理成绩 总分n);printf(%dt%st%st %d %d %d %dn,p-num,p-name,p-sex ,p-score0,p-score1,p-score2,p-sum);printf(nn请输入学号(输入0结束查询):);scanf(%d,&fnum); else if (choose=2)printf(n请输入姓名(输入0结束查询):);scanf(%s,tem); for(;strcmp(tem,0);)for(p=head-next;p!=NULL&strcmp(p-name,tem);p=p-next);if (!p)printf(nn无法查询,请重新输入(输入0结束查询):);scanf(%s,tem);else if (!strcmp(p-name,tem)printf(n%s:n,p-name);printf(学号t姓名t性别t 数学成绩 英语成绩 物理成绩 总分n);printf(%dt%st%st %d %d %d %dn,p-num,p-name,p-sex ,p-score0,p-score1,p-score2,p-sum);printf(nn请输入姓名(输入0结束查询):);scanf(%s,tem);else if (choose=0)printf(n不查询!n);break;elseprintf(n其他选择,视作不查询!n);break; /*/Student *add_new(Student *head) /*插入函数*/Student *p;int flag; printf(nn请输入新加入学生的相关信息(学号为0表示结束输入):n);printf(学号:);scanf(%d,&flag);while(getchar()!=n);for(;flag;) p=(Student *)malloc(LEN);p-num=flag;printf(姓名:);scanf(%s,p-name); printf(性别:); scanf(%s,p-sex);printf(数学成绩:);scanf(%d,&p-score0);printf(英语成绩:);scanf(%d,&p-score1);printf(物理成绩:);scanf(%d,&p-score2);p-sum=p-score0+p-score1+p-score2;p-next=head-next;head-next=p;n+;printf(n请输入新加入学生的相关信息(学号为0表示结束输入):n);printf(学号:);scanf(%d,&flag); head=sort_1(head,1);printf(加入后的成绩表为:n);print(head); return head;/*/void print(Student *head)/*显示函数*/Student *p=head-next;if (!p)printf(nntt+ + + + + 数据为空!+ + + + + +nnn);return;printf(共有【%d】名学生:n,n); printf(+ + + + + + + + + + + + + + + 成绩统计 + + + + + + + + + + + + + + + + +n);printf(学号t姓名t性别t 数学 英语 物理 总分n);for(;p;p=p-next)printf(%dt%st%st %d %d %d %dn,p-num,p-name,p-sex ,p-score0,p-score1,p-score2,p-sum=p-score0+p-score1+p-score2); /*/struct student *del(struct student *head,long num) /*信息删除函数*/struct student *p1,*p2;if(head=NULL)printf(数据为空! n);return head;p1=head;while(num!=p1-num & p1-next!=NULL)p2=p1;p1=p1-next;if(num=p1-num)if(p1=head)head=p1-next;else p2-next=p1-next;printf(已删除:%ldn,num);n=n-1;else printf(未找到:%ldn,num);return(head);/*/int main()/*主函数*/Student *head;int choose,i,num;head=(Student *)malloc(LEN);head-next=NULL; for(;) printf(nnnnnn tt+ + + + + + + + + + + + +

温馨提示

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

评论

0/150

提交评论