学生成绩管理系统报告书.docx
- 文档编号:7331815
- 上传时间:2023-05-11
- 格式:DOCX
- 页数:7
- 大小:84.82KB
学生成绩管理系统报告书.docx
《学生成绩管理系统报告书.docx》由会员分享,可在线阅读,更多相关《学生成绩管理系统报告书.docx(7页珍藏版)》请在冰点文库上搜索。
学生成绩管理系统报告书
计算机科学与技术学院
程序设计报告
程序名称:
学生成绩管理系统
专业:
计算机科学与技术
班级:
计算机1103班
学号:
姓名:
指导老师:
设计日期:
2012年2月24日
学生成绩管理系统
实验目的
1、掌握结构体类型变量的定义和使用;
2、掌握单链表的结构以及对量表的基本操作;
3、掌握文件类型的使用方法;
题目
设学生的记录有学号、姓名、成绩组成。
设计链表数据结构,编程实现以下功能:
1、建立学生记录链表;
2、遍历学生链表;
3、将学生成绩按有高到低排序;
4、向链表中插入结,使链表依然按成绩有序;
5、按指定学号删除学生结点。
源程序代码
#include
#include
#include
voidoutchain(structstud*);//函数说明
voidsortchain(structstud*,int);
voidinsertnode(structstud**,structstudent);
voiddeletenode(structstud**,charx[]);
structstudent//结构定义
{
charno[20];
charname[20];
floatscore;
};
structstud
{
structstudentstu;
structstud*next;
};
voidmain(void)//主函数
{
inti,n;
chara[20];
structstudents;
structstud*head,*p;//定义头指针和遍历指针
head=NULL;
printf("请输入学生人数n=");//输入学生人数
scanf("%d",&n);
printf("**********************\n");
printf("请输入学生数据:
\n");
printf("**********************\n");
for(i=0;i { p=(structstud*)malloc(sizeof(structstud)); printf("学号no: "); scanf("%s",(p->stu).no); printf("姓名: "); scanf("%s",(p->stu).name); printf("成绩: "); scanf("%f",&(p->stu).score); printf("**********************\n"); p->next=head; head=p; } outchain(head);//遍历链表输出学生数据 printf("************************************\n"); sortchain(head,n);//调用排序函数 outchain(head); printf("************************************\n"); printf("输入被插入学生的数据: \n"); printf("学号: ");//输入被插入学生的数据 scanf("%s",s.no); printf("姓名: "); scanf("%s",s.name); printf("成绩: "); scanf("%f",&s.score); insertnode(&head,s);//调用插入函数 outchain(head); printf("************************************\n"); printf("输入要删除学生的学号: "); scanf("%s",a); deletenode(&head,a);//调用删除函数 outchain(head); } voidoutchain(structstud*head)//定义输出函数 { structstud*p; p=head; printf("学号姓名成绩\n"); while(p! =NULL//循环输出结点的数据域 { printf("%s%s%.2f\n",(p->stu).no,(p->stu).name,(p->stu).score); p=p->next;//遍历指针移向下一个结点 } } voidsortchain(structstud*head,intn)//定义排序函数 { inti,j; structstudenttemp; structstud*p1,*p2; for(p1=head,i=0;i for(p2=p1->next,j=i+1;j if((p1->stu).score<(p2->stu).score) { temp=p2->stu; p2->stu=p1->stu; p1->stu=temp; } } voidinsertnode(structstud**headp,structstudentx)//定义插入函数 { structstud*other,*last,*current; other=(structstud*)malloc(sizeof(structstud));//创建一个结点 other->stu=x; current=*headp;//从链头开始查找插入点 while(x.score<(current->stu).score&&(current->next)! =NULL) { last=current; current=current->next; } if(x.score>=(current->stu).score)//插入点不是链尾 if(current==*headp)//在第一个结点之前插入 { other->next=*headp; *headp=other; } else//在中间插入 { other->next=current; last->next=other; } else//插入点是链尾,在链尾结点之后插入 { other->next=NULL; current->next=other; } } voiddeletenode(structstud**headp,charx[20])//定义删除函数 { structstud*p,*last; p=*headp; while(strcmp(p->stu.no,x)! =0&&p->next! =NULL)//查找被删结点 { last=p; p=p->next; } if(strcmp(p->stu.no,x)==0)//找到被删除结点 { if(p==*headp)//被删结点是链头 *headp=p->next; else//被删结点不是链头 last->next=p->next; free(p); } } 截屏运行结果 实验小结 1、要熟练掌握链表建立的两种方式: 头插法和尾插法; 2、通过循环来向链表中输入数据; 3、在理解的基础上熟练掌握对链表的操作: 排序、插入和删除; 4、利用函数来实现整个程序的结构化,从而提高程序的可读性; 5、理解多级指针的含义,掌握多级指针的用法; 6、调用函数时,注意形参与实参的对应关系。
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 学生 成绩管理系统 报告书
![提示](https://static.bingdoc.com/images/bang_tan.gif)