C语言学生管理系统四大典例.docx
- 文档编号:9267347
- 上传时间:2023-02-03
- 格式:DOCX
- 页数:41
- 大小:27.25KB
C语言学生管理系统四大典例.docx
《C语言学生管理系统四大典例.docx》由会员分享,可在线阅读,更多相关《C语言学生管理系统四大典例.docx(41页珍藏版)》请在冰豆网上搜索。
C语言学生管理系统四大典例
学完了C语言,遍了4个学生管理系统的程序
感觉有点儿意思,不过还真的有价值
现在拿出来给大家看看:
一.
某班有最多不超过30人(具体人数由键盘输入)参加某门课程的考试,参考例6.2、例6.4、例6.5,用一维数组作函数参数编程实现如下学生成绩管理:
(1)录入学生的人数;
**要求输入提示信息为:
"Pleaseinputtotalnumber:
\n"
**要求输入数据格式为:
"%d"
(2)录入每个学生的学号和考试成绩;
**要求输入提示信息为:
"Pleaseenterthenumberandscore:
\n"
**要求输入数据格式为:
"%ld,%f"
(3)计算课程的总分和平均分;
**要求输出总分格式为:
"Thetotalscoreis:
%d\n"
**要求输出平均分格式为:
"Theaveragescoreis:
%d\n"
(4)按成绩由高到低排出名次表;
**要求输出提示信息为:
"Sortedresultasscoredecreasing:
\n"
**要求输出格式为:
"%ld,%4.0f\n"
(5)按学号由小到大排出成绩表;
**要求输出提示信息为:
"Sortedresultasnumberincreasing:
\n"
**要求输出格式为:
"%ld,%4.0f\n"
(6)按学号查询学生排名及其考试成绩;
提示信息:
"Pleaseinputthenumberyouwanttosearch:
\n"
**如果未查到此学号的学生,提示信息为:
"Thenumberyouinputisnotexist!
\n"
**如果查询到该学生,要求输出格式为:
"Therankingofnumber%ldis%d,andthescoreis%4.0f\n"
(7)按优秀(90~100)、良好(80~89)、中等(70~79)、及格(60~69)、不及格(0~59)5个类别,统计每个类别的人数以及所占的百分比;
**要求输出提示信息为:
"perfect\t\tgood\t\tmedium\t\tpass\t\tfail\n"
**要求输出人数格式为:
"%.0f\t\t%.0f\t\t%.0f\t\t%.0f\t\t%.0f\n"
**要求输出百分比格式为:
"%.2f%%\t\t%.2f%%\t\t%.2f%%\t\t%.2f%%\t\t%.2f%%\n"
(8)输出每个学生的学号、考试成绩,以及课程总分和平均分。
**要求输出提示信息为:
"Allthenumbersandscoresarebelow:
\n"
**要求输出成绩格式为:
"%ld,%4.0f\n"
**要求输出总分格式为:
"Thetotalscoreis:
%d\n"
**要求输出平均分格式为:
"Theaveragescoreis:
%d\n"
#include
#defineARR_SIZE30
voidsort(floatscore[],longnum[],intn);
voidSS(floatscore[],longnum[],intn);
intSea(longnum[],intn,longx);
intmain()
{
floata=0,b=0,c=0,d=0,e=0,score[ARR_SIZE];
intn,pos,i,temp,totalscore=0,averagescore;
longnum[ARR_SIZE],x;
printf("Pleaseinputtotalnumber:
\n");
scanf("%d",&n);
printf("Pleaseenterthenumberandscore:
\n");
for(i=0;i { scanf("%ld,%f",&num[i],&score[i]); } for(i=0;i { totalscore=totalscore+score[i]; } printf("Thetotalscoreis: %d\nTheaveragescoreis: %d\n",totalscore,totalscore/n); printf("Sortedresultasscoredecreasing: \n"); sort(score,num,n); for(i=0;i { printf("%ld,%4.0f\n",num[i],score[i]); } SS(score,num,n); printf("Sortedresultasnumberincreasing: \n"); for(i=0;i { printf("%ld,%4.0f\n",num[i],score[i]); } printf("Pleaseinputthenumberyouwanttosearch: \n"); scanf("%ld",&x); pos=Sea(num,n,x); if(pos! =-1) { printf("Therankingofnumber%ldis%d,andthescoreis %4.0f\n",x,pos+2,score[pos]); } else { printf("Thenumberyouinputisnotexist! \n"); } printf("perfect\t\tgood\t\tmedium\t\tpass\t\tfail\n"); for(i=0;i { if(score[i]>=90) { a++; } elseif(score[i]>=80) { b++; } elseif(score[i]>=70) { c++; } elseif(score[i]>=60) { d++; } else { e++; } } printf("%.0f\t\t%.0f\t\t%.0f\t\t%.0f\t\t%.0f\n",a,b,c,d,e); printf("%.2f%%\t\t%.2f%%\t\t%.2f%%\t\t%.2f%%\t\t%.2f%%\n",(100*a)/n,(100*b)/n,(100*c)/n,(100*d)/n,(100*e)/n); printf("Allthenumbersandscoresarebelow: \n"); sort(score,num,n); for(i=0;i { printf("%ld,%4.0f\n",num[i],score[i]); } printf("Thetotalscoreis: %d\nTheaveragescoreis: %d\n",totalscore,totalscore/n); return0; }0 voidsort(floatscore[],longnum[],intn) { inti,j; floattemp1; long temp2; for(i=0;i { for(j=i+1;j { if(score[j]>score[i]) { temp1=score[j]; score[j]=score[i]; score[i]=temp1; temp2=num[j]; num[j]=num[i]; num[i]=temp2; } } } } voidSS(floatscore[],longnum[],intn) { inti,j; floattemp1,temp2; for(i=0;i { for(j=i+1;j { if(num[i]>num[j]) { temp1=score[j]; score[j]=score[i]; score[i]=temp1; temp2=num[j]; num[j]=num[i]; num[i]=temp2; } } } } intSea(longnum[],intn,longx) { inti; for(i=0;i { if(num[i]==x) return(i); } return(-1); } 二 学生成绩管理系统V3.0 某班有最多不超过30人(具体人数由键盘输入)参加某门课程的考试,用二维字符数组表示学生姓名作函数参数编程实现如下菜单驱动的学生成绩管理系统: 提示: 当读字符或字符串时,有时需要事先用gets函数过滤掉之前的回车符,所有在codeblock正确运行但在该系统中存在运行超限或输出错误的同学,请把getchar或scanf(" %c");改为gets试试 (1)录入每个学生的学号、姓名和考试成绩; 输入学生人数: **要求输入提示信息为: "Pleaseinputtotalnumber(<=30): \n" **要求输入数据格式为: "%d" **如果输入的数目大于指定最高,则报错退出,提示信息输出为: "Outofrange! \n" 输入学生学号、姓名和成绩: **要求输入提示信息为: "Pleaseenterthenumber,nameandscore: \n" **要求输入学号格式为: "%ld\n" **要求输入姓名用: gets() **要求输入成绩格式为: "%f" **输入完数据后输出: "Thedatahasbeeninputed.\n" (2)计算课程的总分和平均分; **要求输出总分格式为: "Thetotalscoreis: %.1f\n" **要求输出平均分格式为: "Theaveragescoreis: %.1f\n" (3)按成绩由高到低排出名次表; **要求输出提示信息为: "Sortedresultasscoredescending: \n" **要求输出格式为: "%ld,%s,%4.0f\n" (4)按成绩由低到高排出名次表; **要求输出提示信息为: "Sortedresultasscoreascending: \n" **要求输出格式为: "%ld,%s,%4.0f\n" (5)按学号由小到大排出成绩表; **要求输出提示信息为: "Sortedresultasnumberascending: \n" **要求输出格式为: "%ld,%s,%4.0f\n" (6)按姓名的字典顺序排出成绩表; **要求输出提示信息为: "Sortedresultasdictionaryorder: \n" **要求输出格式为: "%ld,%s,%4.0f\n" (7)按学号查询学生排名及其考试成绩; 提示信息: "Pleasethenumberyouwanttosearch: \n" **要求输入数据格式为: "%ld" **如果未查到此学号的学生,提示信息为: "Thenumberyouinputisnotexist! \n" **如果查询到该学生,要求输出格式为: "Therankingofnumber%ldis%d,andthescoreis%4.0f\n" (8)按姓名查询学生排名及其考试成绩; 提示信息: "Pleasethenameyouwanttosearch: \n" **要求输入姓名用: gets() **如果未查到此学号的学生,提示信息为: "Thenameyouinputisnotexist! \n" **如果查询到该学生,要求输出格式为: "Therankingofname%sis%d,andthescoreis%4.0f\n" (9)按优秀(90~100)、良好(80~89)、中等(70~79)、及格(60~69)、不及格(0~59)5个类别,统计每个类别的人数以及所占的百分比; **要求输出提示信息为: "perfect\t\tgood\t\tmedium\t\tpass\t\tfail\n" **要求输出人数格式为: "%.0f\t\t%.0f\t\t%.0f\t\t%.0f\t\t%.0f\n" **要求输出百分比格式为: "%.2f%%\t\t%.2f%%\t\t%.2f%%\t\t%.2f%%\t\t%.2f%%\n" (10)输出每个学生的学号、考试成绩,以及课程总分和平均分。 **要求输出提示信息为: "Allthenumbers,namesandscoresarebelow: \n" **要求输出成绩格式为: "%ld,%s,%4.0f\n" **要求输出总分格式为: "Thetotalscoreis: %.1f\n" **要求输出平均分格式为: "Theaveragescoreis: %.1f\n" (11)要求程序运行后先显示菜单,并提示用户输入选项。 **要求菜单输出信息为: "2.Caculatetotalandaveragescoreofcourse\n" "3.Sortindescendingorderbyscore\n" "4.Sortinascendingorderbyscore\n" "5.Sortinascendingorderbynumber\n" "6.Sortindictionaryorderbyname\n" "7.Searchbynumber\n" "8.Searchbyname\n" "9.Statisticanalysis\n" "10.Listrecord\n" "0.Exit\n" **要求提示用户输入选项信息为: "Pleaseenteryourchoice: \n" **要求输入数据格式为: "%d" (12)当输入0时,输出"Exit\n" #include #include #include #defineARR_SIZE30 voidscorehl(floatscore[],charname[][20],longnum[],intn); voidscorelh(floatscore[],charname[][20],longnum[],intn); voidnumberlh(floatscore[],charname[][20],longnum[],intn); voidnamepx(floatscore[],charname[][20],longnum[],intn); intnumber(floatscore[],charname[][20],longnum[],intn,longx); intFindname(charname[][20],longnum[],floatscore[],intn); void Fenxi(floatscore[],intn); voidprint(longnum[],floatscore[],charname[][20],intn); intmain() { intn,i,m,pos,po,k; char name[ARR_SIZE][20]; floatscore[20]; longnum[40],x; floattotalscore; /*输入学生信息*/ printf("Pleaseinputtotalnumber(<=30): \n"); scanf("%d",&n); printf("Pleaseenterthenumber,nameandscore: \n"); for(i=0;i { scanf("%ld\n",&num[i]); gets(name[i]); scanf("%f",&score[i]); } printf("Thedatahasbeeninputed.\n"); /*打印菜单*/ printf("2.Caculatetotalandaveragescoreofcourse\n"); printf("3.Sortindescendingorderbyscore\n"); printf("4.Sortinascendingorderbyscore\n"); printf("5.Sortinascendingorderbynumber\n"); printf("6.Sortindictionaryorderbyname\n"); printf("7.Searchbynumber\n"); printf("8.Searchbyname\n"); printf("9.Statisticanalysis\n"); printf("10.Listrecord\n"); printf("0.Exit\n"); /*设置循环是可以重复查询*/ do { printf("Pleaseenteryourchoice: \n"); scanf("%d",&m); switch(m) { case2: totalscore=0; for(i=0;i { totalscore=totalscore+score[i]; } printf("Thetotalscoreis: %.1f\nTheaveragescoreis: %.1f\n",tota
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 语言 学生 管理 系统 大典
![提示](https://static.bdocx.com/images/bang_tan.gif)