C语言课程设计报告学籍信息管理系统剖析Word文件下载.docx
- 文档编号:21961465
- 上传时间:2023-02-02
- 格式:DOCX
- 页数:23
- 大小:144.51KB
C语言课程设计报告学籍信息管理系统剖析Word文件下载.docx
《C语言课程设计报告学籍信息管理系统剖析Word文件下载.docx》由会员分享,可在线阅读,更多相关《C语言课程设计报告学籍信息管理系统剖析Word文件下载.docx(23页珍藏版)》请在冰豆网上搜索。
整个系统可以设计为数据录入模块、数据查询模块、数据删除模块和数据排序模块。
二,需求分析
根据题目要求,学籍信息管理系统需要输入和输出等操作,在程序中,需要数据录入,查询,删除,删除和排序功能。
三,解题的思路
1.定义结构
typedefstructstud//学生信息结构
{
longnum;
charname[20];
floatscore;
}Stud;
structstud_type
{
structstud;
chark[3];
intjilu;
};
typedefstructnode
Studstudent;
structnode*next;
}Node;
2.主程序的结构
voidmain()
charchoose;
intflag=1;
while(flag)
duru(stu);
//调用读入函数,读取文件信息;
menu();
//调用功能菜单函数,显示菜单项。
printf("
请选择:
"
);
choose=getchar();
switch(choose)
case'
1'
:
read();
//调用建立链表的函数;
输出链表信息;
print();
\nPressanykeyContinue"
//getchar();
getchar();
break;
2'
//调用按学号查找学生信息的函数;
并输出查找结果信息;
longc;
inputthenumberyouwanttofind:
scanf("
%ld"
&
c);
find(c);
\nPressanykeyContinue."
3'
//调用按姓名查找学生信息的函数;
chars[20];
inputthenameyouwanttofind:
%s"
s);
searchname(s);
\nPressanykeyContinue."
4'
//调用根据学号删除某个学生信息的函数;
并输出删除后的链表信息;
Node*h;
longn;
inputthenumberyouwanttodelete:
n);
h=del(n);
if(h==NULL)printf("
Nofindthestudent\n"
elseprint();
5'
//调用插入新的学生信息的函数;
并输出插入后的链表信息;
longa;
inputthenumberforthenew:
\n"
a);
inser(a);
2;
6'
//调用按分数降序排序输出的函数;
并输出排序后的链表信息;
sort
(1);
sort(0);
7'
Save(stu);
//调用保存函数,保存文件信息;
0'
//结束程序运行!
flag=0;
\n***TheEnd!
***\n"
default:
printf("
\nWrongSelection!
(选择错误,重选)\n"
}
}
3.功能菜单模块
voidmenu()//综合作业功能菜单
\n学生信息管理系统\n"
\n菜单\n\n"
\n1.数据录入\n"
\n2.数据查询(学号)\n"
\n3.数据查询(姓名)\n"
\n4.数据删除\n"
\n5.数据插入\n"
\n6.数据排序\n"
\n7.保存文件信息\n"
\n0.退出\n\n"
}
4.输入模块
voidread(void)
inputthenumber:
while(a>
0){3;
5.检查输入错误模块
voidinser(longb)
Node*last,*current,*p;
current=head;
while(current!
=NULL&
&
b>
current->
student.num)
last=current;
current=current->
next;
if(current==NULL||b<
inputthename,score:
p=(Node*)malloc(sizeof(Node));
p->
student.num=b;
%s%f"
p->
student.name,&
student.score);
next=NULL;
if(current==head)
next=head;
head=p;
Else
next=current;
last->
next=p;
elseif(b==current->
student.num)
errorinputadifferentnumber:
6.输出模块
voidprint()
Node*p=head;
学号姓名成绩:
while(p!
=NULL)
%ld%s%f\n"
student.num,p->
student.name,p->
p=p->
}4;
7.查询模块
voidfind(longb)
b!
=p->
if(!
p)printf("
Nofound\n"
else
学号姓名成绩\n"
voidsearchname(char*s)
intflag=0;
=NULL)
if(strcmp(p->
student.name,s)==0)
flag=1;
continue;
elsep=p->
flag)printf("
Nofind"
Node*del(longn)
Node*p=head,*last;
while(p->
student.num!
=n){
last=p;
if(p==NULL)returnp;
elseif(p==head)head=p->
elselast->
next=p->
5;
returnhead;
8.排序模块
voidsort(intflag)
/*flag==1按分数排序else按学号排序*/
Node*p1,*p2,*k;
floatt1;
longt2;
for(p1=head;
p1->
p1=p1->
next)
k=p1;
for(p2=p1->
p2;
p2=p2->
if(flag==1&
k->
student.score<
p2->
student.score||!
flag&
student.num>
k=p2;
if(k!
=p1)
t1=p1->
student.score;
student.score=k->
student.score=t1;
t2=p1->
student.num;
student.num=k->
student.num=t2;
strcpy(s,p1->
student.name);
strcpy(p1->
student.name,k->
strcpy(k->
student.name,s);
9.保存模块
voidSave(structstud_typestu[])/*保存模块*/
inti;
FILE*fp1;
/*指向文件的指针*/
stu[0].jilu=r;
if((fp1=fopen("
E:
\\cj1.txt"
"
wb"
))==NULL)/*打开文件,并判断打开是否正常,wb指只写打开或建立一个二进制文件,只允许写数据*/
{
----------打开文件失败!
----------\n\n"
return;
开始存盘!
for(i=0;
i<
r;
i++)
if(fwrite(&
stu[i],sizeof(structstud_type),1,fp1)==0)
----------数据存盘失败!
fclose(fp1);
----------存盘成功!
----------\n"
/*显示保存成功*/
10.读入模块
voidduru(structstud_typestu[])/*数据读入模块*/
FILE*fp;
if((fp=fopen("
rb"
))==NULL)/*打开文件,并判断打开是否正常,rb指读写打开一个二进制文件,允许读和写*/
打开文件失败!
文件开始读取!
rewind(fp);
=r;
fread(&
stu[i],sizeof(structstud_type),1,fp);
r=stu[0].jilu;
\n文件成功读取!
fclose(fp);
四,运行与测试报告
五,设计体会
通过这次的程序设计实习,自己编写程序,从上百个错误慢慢的修改,经过自己的努力和老师的细心教导之下,错误逐渐的变少,最终可以运行了,这次的实习中,我磨练了自己的毅力和耐力,让我的信心倍增,在这短短的24的学时里,我体会到了苦与甜,更让我学到了很多的知识,在以后的工作中肯定会非常有用的,使对未来的生活充满了信心。
附录:
#include<
stdio.h>
string.h>
stdlib.h>
math.h>
#defineN100
structstud_typestu[N];
Node*head=NULL;
voidread(void);
voidinser(longb);
voidprint();
voidfind(longb);
voidsearchname(char*s);
Node*del(longn);
voidsort(intflag);
voidmenu();
voidSave(structstud_typestu[]);
voidPrint(structstud_typestu[]);
voidduru(structstud_typestu[]);
intr=0;
inputthenumberforthenew学号:
学号:
0)
inputthe姓名,学分:
=NULL){
else{
student.name,
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 语言 课程设计 报告 学籍 信息管理 系统 剖析
![提示](https://static.bdocx.com/images/bang_tan.gif)