C语言综合性实验报告1Word下载.docx
- 文档编号:18683196
- 上传时间:2022-12-31
- 格式:DOCX
- 页数:14
- 大小:176.15KB
C语言综合性实验报告1Word下载.docx
《C语言综合性实验报告1Word下载.docx》由会员分享,可在线阅读,更多相关《C语言综合性实验报告1Word下载.docx(14页珍藏版)》请在冰豆网上搜索。
structxsnode
{
intxh;
charxm[15];
intgs;
intyy;
intwl;
floatpj;
intmc;
structxsnode*next;
}stu[100];
intlength;
/*全局变量*/
FILE*fp=NULL;
/*定义指针*/
/*********************成绩录入********************/
structxsnode*luru()
{structxsnode*p1,*p2,*head;
inti,sum=0,flag=1;
system("
cls"
);
/*刷屏*/
while(flag==1)
{printf("
inputlengthoflist(<
100):
"
scanf("
%d"
&
length);
if(length<
100)
flag=0;
}
for(i=0;
i<
length;
i++)
{p1=(structxsnode*)malloc(LEN);
if(i==0)
head=p2=p1;
else
p2->
next=p1;
p2=p1;
printf("
No.:
p1->
xh);
name:
%s"
xm);
gscj:
gs);
yycj:
yy);
wlcj:
wl);
sum=p1->
gs+p1->
yy+p1->
wl;
p1->
pj=(float)(sum/3.0);
next=NULL;
fp=fopen("
stud1"
"
w"
if(fwrite(&
stu[i],sizeof(structxsnode),1,fp)!
=1)
filewriteerror\n"
fclose(fp);
return(head);
}
/********************成绩修改********************/
voidxiugai(structxsnode*head)
{structxsnode*p1,*p2;
p1=head;
intxh1,i=0,sum=0;
请输入要修改的学生的学号:
xh1);
while(xh1!
=p1->
xh&
&
next!
=NULL)
{p2=p1;
p1=p1->
next;
i++;
if(xh1==p1->
xh)
要修改的学生信息为:
\n"
%6d%8s%8d%8d%8d"
p1->
xh,p1->
xm,p1->
gs,p1->
yy,p1->
\n请重新输入学生信息(学号、姓名、高数成绩、英语成绩、物理成绩):
%d%s%d%d%d"
xh,&
xm,&
gs,&
yy,&
if((fp=fopen("
r"
))==NULL)
文件不能打开!
exit(0);
fwrite(&
stu[i],sizeof(structxsnode),1,fp);
/********************成绩删除*********************/
voidshanchu(structxsnode*head)
{
intfind;
intxh1,i=0,j=0;
structxsnode*p,*pt;
输入要删除的学生的学号:
pt=head;
p=pt;
if(pt->
xh==xh1)
{
p=pt->
head=pt=p;
find=1;
pt=pt->
while(pt!
{i++;
if(pt->
{
p->
next=pt->
find=1;
}
else
p=pt;
pt=pt->
if(find!
printf("
Notfound%s"
xh1);
p=head;
for(j=0;
j<
i||j>
i&
j++)
length--;
/***********************成绩查询**************************/
voidchaxun(structxsnode*head)
intxh2;
structxsnode*p;
输入学号为0表示退出查询:
所查找学号:
xh2);
while(p!
=NULL&
xh2!
=0)
if(p->
xh==xh2)
printf("
No.namegscjyycjwlcj\n"
p->
xh,p->
xm,p->
gs,p->
yy,p->
p=p->
if(xh2==0)
inputerrorandexit!
getch();
/********************成绩浏览**********************/
voidliulan(structxsnode*head)
{structxsnodest;
structxsnode*p;
inti=0,k=1,j;
floatmc[100];
No.namegscjyycjwlcjpjcj\n"
%6d%8s%8d%8d%8d%8.2f\n"
wl,p->
pj);
mc[i]=p->
pj;
i++;
p=p->
}for(j=0;
j++)
if(mc[j]<
mc[i]&
j!
=i)
k=k+1;
学号对应名次如下:
%d\n"
k);
k=1;
voidmain()
{intc,flag=0;
structxsnode*head;
\n\n\n\n\t\t\t##################\n"
\t\t\t##\n"
\t\t\t#--欢迎使用学生管理系统--#\n"
\t\t\t\n"
\t\t\t#----计算B101肖圣龙----#\n"
\t\t\t##################\n"
while(flag==0)
{system("
\n\n\n\n"
\t\t\t*****************************************\n"
\t\t\t*1.成绩录入*\n"
\t\t\t**\n"
\t\t\t*2.成绩修改*\n"
\t\t\t*3.成绩查询*\n"
\t\t\t*4.成绩浏览*\n"
\t\t\t*5.成绩删除*\n"
\t\t\t*6.退出系统*\n"
\t\t\t请按数字键1~6,进行相应操作:
c);
fflush(stdin);
/*刷新缓冲区*/
switch(c)
case1:
head=luru();
break;
case2:
xiugai(head);
case3:
chaxun(head);
case4:
liulan(head);
case5:
shanchu(head);
case6:
flag=1;
default:
\t\t<
没有此选项,按任意键重新选择!
>
if(flag==1)break;
\t\t\t#--谢谢使用--#\n"
}四、实验结果及分析
第一步:
运行,出现下面屏幕
第二步:
按回车进入下面屏幕,
(1)成绩录入:
(2)成绩修改:
(3)成绩查询:
(4)成绩浏览:
(5)成绩删除后浏览:
(6)退出系统:
二.(心得)
对整体C语言来讲,它是一门具有很强的严谨性的课程。
首先你的有一个整体的观念,设计好整体的实验功能,比如结构体的运用,链表的运用,成绩录入函数,成绩修改函数,成绩查询函数,成绩浏览函数……
从最开始的打稿,就要做好每个程序的编写,小到一个符号,都要做好认真的检查。
编译过程中,由于程序函数比较多,进行一个一个处理。
每个程序都成功运行,在进行整体合并。
当出现错误时,我就用上我自己学习的设置断点,进行调试。
总体来说,一个程序的完成,是对一个人的一次考验,身体的考验,精神的考验,更加能锻炼人严谨的心。
教师评价
评定项目
A
B
C
D
算法正确
界面美观,布局合理
程序结构合理
操作熟练
语法、语义正确
解析完整
实验结果正确
文字流畅
报告规范
题解正确
其他:
评价教师签名:
年月日
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 语言 综合性 实验 报告