C语言程序设计基于链表的学生成绩管理系统.docx

上传人:b****2 文档编号:2314808 上传时间:2022-10-28 格式:DOCX 页数:20 大小:18.82KB
下载 相关 举报
C语言程序设计基于链表的学生成绩管理系统.docx_第1页
第1页 / 共20页
C语言程序设计基于链表的学生成绩管理系统.docx_第2页
第2页 / 共20页
C语言程序设计基于链表的学生成绩管理系统.docx_第3页
第3页 / 共20页
C语言程序设计基于链表的学生成绩管理系统.docx_第4页
第4页 / 共20页
C语言程序设计基于链表的学生成绩管理系统.docx_第5页
第5页 / 共20页
点击查看更多>>
下载资源
资源描述

C语言程序设计基于链表的学生成绩管理系统.docx

《C语言程序设计基于链表的学生成绩管理系统.docx》由会员分享,可在线阅读,更多相关《C语言程序设计基于链表的学生成绩管理系统.docx(20页珍藏版)》请在冰豆网上搜索。

C语言程序设计基于链表的学生成绩管理系统.docx

C语言程序设计基于链表的学生成绩管理系统

华北科技学院计算机系综合性实验

实验报告

课程名称C语言程序设计

实验学期2011至2012学年第二学期

学生所在系部计算机系

年级2011专业班级计算机科学与技术B-111

学生姓名学号

任课教师

实验成绩

计算机系制

实验报告须知

1、学生上交实验报告时,必须为打印稿(A4纸)。

页面空间不够,可以顺延。

2、学生应该填写的内容包括:

封面相关栏目、实验地点、时间、目的、设备环境、内容、结果及分析等。

3、教师应该填写的内容包括:

实验成绩、教师评价等。

4、教师根据本课程的《综合性实验指导单》中实验内容的要求,评定学生的综合性实验成绩;要求在该课程期末考试前将实验报告交给任课教师。

综合性实验中,所涉及的程序,文档等在交实验报告前,拷贝给任课教师。

任课教师统一刻录成光盘,与该课程的期末考试成绩一同上交到系里存档。

5、未尽事宜,请参考该课程的实验大纲和教学大纲。

《C语言程序设计》课程综合性实验报告

开课实验室:

基础五2012年7月6日

实验题目

基于链表的学生成绩管理系统

一、实验目的

1、掌握链表的创建、遍历显示和清除;

2、掌握链表数据的文件保存、读取;

二、设备与环境

微型计算机、VC++6.0

三、实验内容

1、定义结构体,创建链表

structxsnode

{

  intxh;

  charxm[15];

  intgs;

  intyy;

  intwl;

  structxsnode*next;

};

2、根据以上链表结点结构,实现以下功能

a、学生学号、姓名、各门成绩的录入;

b、链表数据显示及清除;

c、链表数据的文件保存与读取;

四、实验结果及分析

1、运行结果

主菜单

数据显示

2、源程序

主函数

voidmain()

{

intxz=0;

structxs*head;

head=init();

while(xz!

=5)

{

menu();

scanf("%d",&xz);

switch(xz)

{

case1:

create(head);

break;

case2:

print(head);

break;

case3:

save(head);

break;

case4:

read(head);

break;

case5:

printf("\n系统退出,拜拜!

\n");

break;

default:

printf("\n选择错误,请按任意键选择!

\n");

getch();

break;

}

}

fr(head);

free(head);

}

数据录入源代码

voidcreate(structxs*hd)

{

intxh,gs,yy,wl,i;

charxm[20];

structxs*p;

fr(hd);

printf("\n请输入学生个数:

");

scanf("%d",&num);

for(i=0;i

{

printf("请输入%d个学生of%d\n",i+1,num);

printf("学号:

");

scanf("%d",&xh);

printf("姓名:

");

scanf("%s",xm);

printf("高数:

");

scanf("%d",&gs);

printf("英语:

");

scanf("%d",&yy);

printf("物理:

");

scanf("%d",&wl);

p=(structxs*)malloc(sizeof(structxs));

p->xh=xh;

strcpy(p->xm,xm);

p->gs=gs;

p->yy=yy;

p->wl=wl;

p->next=hd->next;

hd->next=p;

}

printf("录入数据完毕,请按任意键继续!

\n");

getch();

}

添加记录源代码

voidprint(structxs*hd)

{

structxs*p;

p=hd->next;

if(p!

=NULL)

{

printf("\n数据显示\n");

printf("**********************************************\n");

printf("学号姓名高数英语物理平均分\n");

printf("**********************************************\n");

while(p!

=NULL)

{

printf("%4d",p->xh);

printf("%10s",p->xm);

printf("%8d",p->gs);

printf("%7d",p->yy);

printf("%6d",p->wl);

printf("%8.2f\n",(p->wl+p->wl+p->wl)/3.0);

p=p->next;

}

printf("**********************************************\n");

printf("链表显示完毕,请按任意键继续!

\n");

getch();

}

else

printf("\n当前链表为空,请先读取文件或创建链表!

\n按任意键继续!

\n");

}

查询记录源代码

voidmenu()

{

system("cls");

printf("****************************************\n");

printf("*学生成绩管理系统(1.0)*\n");

printf("****************************************\n");

printf("*jb11-131宋洁2012-7-3*\n");

printf("****************************************\n");

printf("*1-创建链表*\n");

printf("*2-数据显示*\n");

printf("*3-保存文件*\n");

printf("*4-读取文件*\n");

printf("*5-系统退出*\n");

printf("****************************************\n");

printf("请选择操作(1-5:

");

}

源程序

#include"stdio.h"

#include"stdlib.h"

#include

#include"conio.h"

structxs

{

intxh;

charxm[20];

intgs,yy,wl;

structxs*next;

};

intnum=0;

structxs*init()

{

structxs*hd;

hd=(structxs*)malloc(sizeof(structxs));

hd->next=NULL;

returnhd;

}

voidfr(structxs*hd)

{

structxs*p;

p=hd->next;

while(hd->next!

=NULL)

{

p=hd->next;

hd->next=p->next;

free(p);

}

}

voidcreate(structxs*hd)

{

intxh,gs,yy,wl,i;

charxm[20];

structxs*p;

fr(hd);

printf("\n请输入学生个数:

");

scanf("%d",&num);

for(i=0;i

{

printf("请输入%d个学生of%d\n",i+1,num);

printf("学号:

");

scanf("%d",&xh);

printf("姓名:

");

scanf("%s",xm);

printf("高数:

");

scanf("%d",&gs);

printf("英语:

");

scanf("%d",&yy);

printf("物理:

");

scanf("%d",&wl);

p=(structxs*)malloc(sizeof(structxs));

p->xh=xh;

strcpy(p->xm,xm);

p->gs=gs;

p->yy=yy;

p->wl=wl;

p->next=hd->next;

hd->next=p;

}

printf("录入数据完毕,请按任意键继续!

\n");

getch();

}

voidsave(structxs*hd)

{

if(hd->next!

=NULL)

{

structxs*p=hd->next;

inti;

FILE*fp;

fp=fopen("yh.txt","w");

fprintf(fp,"%3d\n",num);

for(i=0;i

{

fprintf(fp,"%3d%12s%3d%3d%3d\n",p->xh,p->xm,p->gs,p->yy,p->wl);

p=p->next;

}

fclose(fp);

printf("\n保存文件完毕,请按任意键继续!

\n");

getch();

}

else

{

printf("\n当前链表为空,不需要保存,请按任意键继续!

\n");

getch();

}

}

voidread(structxs*hd)

{

inti;

structxs*p;

FILE*fp;

fr(hd);

fp=fopen("yh.txt","r");

fscanf(fp,"%3d\n",&num);

for(i=0;i

{

p=(structxs*)malloc(sizeof(structxs));

fscanf(fp,"%3d%12s%3d%3d%3d\n",p->xh,p->xm,p->gs,p->yy,p->wl);

p->next=hd->next;

hd->next=p;

}

fclose(fp);

printf("\n读取文件完毕,请按任意键继续!

\n");

getch();

}

voidprint(structxs*hd)

{

structxs*p;

p=hd->next;

if(p!

=NULL)

{

printf("\n数据显示\n");

printf("**********************************************\n");

printf("学号姓名高数英语物理平均分\n");

printf("**********************************************\n");

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 人文社科 > 法律资料

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1