


版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、#in clude<stdio.h>#in clude<stdlib.h>#in clude<stri ng.h>#defi ne stu 30int menu (void);void readche ngji(lo ng xuehao,float che ngji,i nt n);void aversumofche ngji(float xuehao,i nt n);void desortbyche ngji(l ong xuehao,float che ngji,i nt n); void assortbyxuehao(l ong xuehao,floa
2、t che ngji,i nt n); void searchbyxuehao(l ong xuehao,float che ngji,i nt n); void statistica nalysis(float che ngji,i nt n);void prin tche ngji(l ong xuehao,float che ngji,i nt n);int mai n ()char itemSelected;char mima10;int n ,j=0;float che ngjistu;long xuehaostu;char yaosi="6251"char c;
3、printf("ttt学生成绩管理系统n");printf("请输入密码:”);ago:j=0;while(c=getch()!=13)putchar('*');mimaj=c;j+;mimaj='0' getchar();if (strcmp(mima,yaosi)=0)goto loop;elseprintf("密码错误,请重新输入:");prin tf("a");prin tf("a");prin tf("a");goto ago;loop:pri
4、ntf("输入学生人数 n<%d :",stu);shuru:scan f("%d",&n);if(n> stu)printf("输入错误,请重新输入:");prin tf("a");prin tf("a");prin tf("a");goto shuru;while (1)/当非零的时候/itemSelected=me nu();显示菜单,并读取用户输入/switch (itemSelected)case 1: readche ngji(xuehao,c
5、he ngji ,n);break;case 2: aversumofche ngji(che ngji, n);break;case 3:desortbyche ngji(xuehao,che ngji, n);printf("n成绩降序排列:n学号t成绩n”);prin tche ngji(xuehao,che ngji, n);break;case 4: assortbyxuehao(xuehao,che ngji, n);printf("n学号升序排列:n学号t成绩n”);prin tche ngji(xuehao,che ngji, n);break;case 5
6、: searchbyxuehao(xuehao,che ngji, n);break;case 6: statistica nalysis(che ngji, n);break;case 7: prin tche ngji(xuehao,che ngji, n);break;case 0: exit(0);printf("程序结束!");break;default:printf("输入错误! ”);break;return 0;/函数功能:显示菜单并获得用户键盘输入的选项/int menu (void)int itemSelected;printf("n
7、学生成绩的管理n");printf("t1.学号成绩录入n");prin tf("t2 计算总分和平均分n");printf("t3.根据成绩降序排列n");printf("t4.按照学号升序排列n");printf("t5.按学号查询 n");printf("t6.统计分析 n");printf("t7.列表记录 n");printf("t0.退出 n"); printf("请输入你的选择:");scan
8、 f("%d", &itemSelected); return itemSelected;输入n个学生的某门课成绩/void readche ngji(lo ng xuehao,float che ngji,i nt n)int i;printf("输入学生学号,成绩:n");for (i=0;i <n ;i+)scan f("%ld%f", &xuehaoi,&chen gjii);计算全班总分和平均分 void aversumofche ngji(float che ngji,i nt n)int i
9、;float sum=0;for(i=0;i< n;i+)sum=sum+che ngjii;printf("总分数=%.0f,平均分=%.2fn",sum,n>0?sum/n:0);/按选择法将数组chengji的元素按从高到低排序/void desortbyche ngji(l ong xuehao,float che ngji,i nt n)int i,j,k;float templ1;long templ2;for (i=0;i<=n _1;i+)k=i;for(j=i+1;j< n;j+)if(che ngjij>che ngjik)
10、k=j;if (k!=i)tempi仁che ngjik;che ngjik=che ngjii;chengjii=templ1; 交换成绩 / templ2=xuehaok;xuehaok=xuehaoi;xuehaoi=templ2; 交换学号 /按选择法将数组xuehao的元素值按从低到高排序/ void assortbyxuehao(l ong xuehao,float che ngji,i nt n) int i,j,k;float n1;long n2;for (i=0;i<=n _1;i+)k=i;for(j=i+1;j< n;j+)if(xuehaoj<xue
11、haok)k=j;if (k!=i)n 1=che ngjik;che ngjik=che ngjii;chengjii=n1; 交换成绩 /n 2=xuehaok;xuehaok=xuehaoi;xuehaoi=n2; 交换学号 /按学号查找学生成绩并显示查找结果/void searchbyxuehao(l ong xuehao,float che ngji,i nt n) long nu mber;int i;printf("输入你要查询的学号:”);scan f("%ld", &n umber);for (i=0;i <n ;i+)if(xue
12、haoi=nu mber)prin tf("%ldt%.0fn",xuehaoi,che ngjii); return;printf("n 未查询到! n");/统计各分数段的学生人数及所占的百分比/void statistica nalysis(float che ngji,i nt n)int i,total=0,t6=0,0,0,0,0,0;for (i=0;i <n ;i+)if(che ngjii>=0&&che ngjii<60)t0+;else if(che ngjii<70)t1+;else if(
13、che ngjii<80)t2+;else if(che ngjii<90)t3+;else if(che ngjii<100)t4+;else if(che ngjii=100)t5+;for(i=0;i<=5;i+)total=total+ti;if(total!=n)printf("成绩输入不在正确的范围”);return;printf("n分数段t人数t百分比n");for(i=0;i<=5;i+)if(i=0)prin tf("<60t%dt%.2f%n",ti,(float)ti/n*100);else if(i=5)prin tf("%dt%dt%.2f%n",(i+5)*10, ti ,(float)ti/n*100);elseprin t
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 大学生心理健康教育 课件 第七章 大学生健康恋爱及性心理的培养
- 应急安全体验馆培训课件
- 2024年浙江省东阳市中考物理高频难、易错点题(A卷)附答案详解
- 秋季腹部保暖与肠道功能关联研究
- 水利设施管养人员考前冲刺试卷附参考答案详解【夺分金卷】
- 2025自考专业(汉语言文学)复习提分资料带答案详解(典型题)
- 2024-2025学年计算机二级过关检测试卷附答案详解【B卷】
- 2025年教育行业并购动态:投资策略与整合路径研究报告
- 2025年老旧小区电梯加装工程社会效益分析报告
- 2025年工业互联网平台微服务架构性能测试报告:工业互联网平台在能源管理中的应用
- 2025年北京市高考英语试卷真题(含答案解析)
- 医务科依法执业自查表
- 综合实践活动(2年级下册)第3课时 自动浇水器的设计与制作-课件
- 保密室及保密要害部位搬迁发案
- 拍卖行业发展趋势PPT
- 《人力资源管理全套课件》
- 眼科常见疾病诊疗指南
- 厂级岗前安全培训教材
- 征兵宣传主题PPT
- 全桥LLC自动计算表格
- 高中数学竞赛讲义-高中数学竞赛
评论
0/150
提交评论