c语言学籍管理系统实验报告.docx
- 文档编号:12119739
- 上传时间:2023-04-17
- 格式:DOCX
- 页数:9
- 大小:77.24KB
c语言学籍管理系统实验报告.docx
《c语言学籍管理系统实验报告.docx》由会员分享,可在线阅读,更多相关《c语言学籍管理系统实验报告.docx(9页珍藏版)》请在冰豆网上搜索。
c语言学籍管理系统实验报告
c语言学籍管理系统实验报告
实验报告
课程程序设计基础实验名称课内实验共5页
系别 计算机系专业班级 姓名学号
实验题目:
使用C编程实现一个学籍管理系统
1.程序设计与分析
程序实现的功能
1.提供基本的菜单选项,能根据不同的选项执行不同操作;
2.对学生信息进行录入信息、删除学生信息、查询信息、学生信息排序、学生信息统计输出的操作;
数据类型
学生信息:
结构体数组
学生学号、班级、姓名:
字符串数组
学生的三个成绩及总分:
浮点型变量
用户选项、计数器:
整形变量
各个功能模块:
被调函数
核心算法
2.程序设计中存在的问题和解决思路
存在问题:
1.从调用函数返回主函数后无法再次调用主函数。
2.全程使用数组而没用指针。
1.
2.熟练掌握输入输出语句。
3.学会分块编译程序,调试程序更加熟练。
不足:
1.对于指针的理解不足,没有用指针做成链表进行函数间的调用。
2.尚存在一些基础性的语法错误,这要通过复习课本、上机实验来消灭这些错误。
3.对于调用函数掌握不足,可以尝试着做一些带返回值的函数。
4.源代码清单
#include
#include
structStudent
{
charid[10];charcla[10];charname[10];floatscore1;floatscore2;floatscore3;floatsum;
}stu[3],mark,temp,*p;/*学生信息结构体数组,mark用来标记待删除的学生信息,temp用来交换,*p指向结构体数组*/
intchoice,i,j;
charstr1[10],str2[10]={"no"};//用以判断是否继续
voidhomepage()//输出主页面并获取用户的选项
{
printf("1.input\n2.delete\n3.select\n4.order\n5.output\n6.quit\npleaseinputyouroption\n");
scanf("%d",&choice);
}
voidinput()//输入学生信息
{
for(i=0;;i++,p++)
{
printf("id");scanf("%s",&stu[i].id);
printf("class");scanf("%s",&stu[i].cla);
printf("name");scanf("%s",&stu[i].name);
printf("score1");scanf("%f",&stu[i].score1);
printf("score2");scanf("%f",&stu[i].score2);
printf("score3");scanf("%f",&stu[i].score3);
stu[i].sum=stu[i].score1+stu[i].score2+stu[i].score3;
printf("continue?
\n");scanf("%s",str1);
if(strcmp(str1,str2)==0)break;
}
return;
}
voiddel()//用指针将数据输出,将用户想找到的学生信息进行标记
{
charfind[10];scanf("%s",find);
for(i=0,p=stu;i<3,p { if((strcmp(stu[i].name,find)! =0)&&(strcmp(stu[i].id,find)! =0)) { printf("%s,%s,",p->id,p->cla); printf("%s,",p->name); printf("%4.1f,%4.1f,%4.1f,",p->score1,p->score2,p->score3); printf("%5.1f\n",p->sum); } if((strcmp(stu[i].name,find)==0)||(strcmp(stu[i].id,find)==0)) mark=stu[i]; } printf("continue? \n");scanf("%s",str1); if(strcmp(str1,str2)==0)return; elsedel(); } voidselect()/*用find字符串数组查找用户希望查找的信息,利用num作为计数器来判断是否查找到*/ { charfind[10];scanf("%s",find);intnum=0; for(i=0,p=stu;i<3,p { if((strcmp(stu[i].id,find)==0)||(strcmp(stu[i].cla,find)==0)) { printf("%s,%s,",p->id,p->cla);printf("%s,",p->name); printf("%4.1f,%4.1f,%4.1f,",p->score1,p->score2,p->score3); printf("%5.1f\n",p->sum);num=num+1; } } if(num==0) {printf("thereisnoeligiblestudent");return;} if(num! =0) { printf("continue? \n");scanf("%s",str1); if(strcmp(str1,str2)==0)return; elseselect(); } } voidorder()//先以班级字符串大小为标准排序,再以总分大小排序,直接交换结构体 { for(i=0;i<2;i++){for(j=0;j<(2-i);j++){if(strcmp(stu[j].cla,stu[j+1].cla)>0){temp=stu[j];stu[j]=stu[j+1];stu[j+1]=temp;}}} for(i=0;i<2;i++){for(j=0;j<(2-i);j++){if(stu[j].sum>stu[j+1].sum){temp=stu[j];stu[j]=stu[j+1];stu[j+1]=temp;}}} for(i=0,p=stu;i<3,p { if((strcmp(stu[i].name,mark.name)! =0)) { printf("%s,%s,",p->id,p->cla);printf("%s,",p->name); printf("%4.1f,%4.1f,%4.1f,",p->score1,p->score2,p->score3); printf("%5.1f\n",p->sum); } } return; } voidoutput()//根据上面的结果输出学生信息 { for(i=0,p=stu;i<3,p { if((strcmp(stu[i].name,mark.name)! =0)) { printf("%s,%s,",p->id,p->cla);printf("%s,",p->name); printf("%4.1f,%4.1f,%4.1f,",p->score1,p->score2,p->score3); printf("%5.1f\n",p->sum); } } return; } intmain() { while (1)/*每次调用函数返回时若为真,则进入循环体、进入主界面,若用户选择为6退出,则跳出循环*/ { homepage(); switch(choice) { case1: input();break; case2: del();break; case3: select();break; case4: order();break; case5: output();break; case6: break; } if(choice==6)break; } return0; }
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 语言 学籍 管理 系统 实验 报告