学生籍贯信息记录簿C语言课程设计.docx
- 文档编号:2812882
- 上传时间:2022-11-15
- 格式:DOCX
- 页数:48
- 大小:282.96KB
学生籍贯信息记录簿C语言课程设计.docx
《学生籍贯信息记录簿C语言课程设计.docx》由会员分享,可在线阅读,更多相关《学生籍贯信息记录簿C语言课程设计.docx(48页珍藏版)》请在冰豆网上搜索。
学生籍贯信息记录簿C语言课程设计
HUNANUNIVERSITY
程序设计训练
报告
学生姓名岳全有邓江军
学生学号**********************
专业班级电气工程及其自动化
指导老师黄友荣
院长(系主任)王耀南
2011年7月8日
一.设计内容与要求
编制一个学生籍贯信息记录簿,每个学生信息包括:
学号、姓名、籍贯。
具体功能要求如下:
1.创建信息链表并以磁盘文件保存;
2.读取磁盘文件并显示输出所有学生的籍贯信息;
3.按学号或姓名查询其籍贯;
4.按籍贯查询并输出该籍贯的所有学生;
5.能添加、删除和修改学生的籍贯信息;
6.显示输出江苏籍和非江苏籍学生的信息并可分别存盘。
二.主要技术指标及特点
3.0信息描述(注:
用流程图表示)
2.1创建信息链表并以磁盘文件保存;
/**********************建立链表******************************/
structhj
{longnumber;
charname[10],address[50];
structhj*next;
};
/*********************文件操作函数******************************/
FILE*fp;
voidopenfile(charxx[20])
{
fp=fopen(xx,"ab+");
if(fp==NULL)
fp=fopen(xx,"wb");
}
/************************主函数********************************/
intmain(intargc,char*argv[])
{
begin:
intt;
system("cls");
printf("\n★★★★★欢迎使用户籍管理系统★★★★★\n\n\n\n\n");
printf("一录入学生籍贯信息\n\n");
printf("二查编学生籍贯信息\n\n");
printf("三删除学生籍贯信息\n\n");
printf("四退出程序\n\n");
printf("请您选择:
");
mm:
scanf("%d",&t);
switch(t)
{
case1:
hjnew();break;
case2:
hjselect();break;
case3:
hjde();break;
case4:
exit(0);
default:
printf("\n错误的选择,请重新选择:
");
gotomm;
}
gotobegin;
return0;
}
2.2读取磁盘文件并显示输出所有学生的籍贯信息;
voidallselect(chara[8])//全部查询
{
intn=0;
intk=0;
system("cls");
printf("\n★★★★★欢迎使用户籍管理系统★★★★★\n");
printf("\n★★★籍贯方式信息★★★\n\n\n");
structhj*p;
structhj*q=NULL,*head=NULL;
fp=fopen(a,"rb");
if(fp==NULL)
{
printf("\n对不起,没有记录无法查询!
");
gotoxxxx;
}
rewind(fp);
while(!
feof(fp))
{
n++;
p=(structhj*)malloc(sizeof(structhj));
fread(p,sizeof(structhj),1,fp);
if(n==1)
head=p;
else
q->next=p;
q=p;
}
q->next=NULL;
structhj*h1,*p2,*q3,*r4,*s5;
h1=p2=(hj*)malloc(sizeof(structhj));
p2->next=head;
while(p2->next!
=NULL)
{
q3=p2->next;
r4=p2;
while(q3->next!
=NULL)
{
if(q3->next->number
r4=q3;
q3=q3->next;
}
if(r4!
=p2)
{
s5=r4->next;
r4->next=s5->next;
s5->next=p2->next;
p2->next=s5;
}
p2=p2->next;
}
head=h1->next->next;
free(h1);
p=head;
while(p!
=NULL&&n>0)
{
n--;
printf("\n学号=%ld姓名=%s",p->number,p->name);
printf("\n地址=%s",p->address);
p=p->next;
}
xxxx:
printf("\n→显示完毕←\n⑴↑返回上级菜单⑵↓退出程序\n请选择:
");
xxx:
scanf("%d",&n);
switch(n)
{
case1:
break;
case2:
exit(0);
default:
printf("\n错误的选择,请重新选择:
");
gotoxxx;
}
}
voidhjselect(void)//查询编辑信息函数
{
cxbegin:
inta;
system("cls");
printf("\n★★★★★欢迎使用户籍管理系统★★★★★\n");
printf("\n★★★查询编辑信息★★★\n\n\n");
printf("\n一按学号方式查询\n");
printf("\n二按姓名方式查询\n");
printf("\n三按籍贯方式查询\n");
printf("\n四→显示全部信息\n");
printf("\n五←返回上级菜单\n");
printf("\n请选择查询方式:
");
cxmm:
scanf("%d",&a);
switch(a)
{
case1:
hjxmselect();gotocxbegin;break;
case2:
hjxhselect();gotocxbegin;break;
case3:
hjjgselect();gotocxbegin;break;
case4:
allselect("hj.txt");gotocxbegin;break;
case5:
break;
default:
printf("\n错误的选择,请重新选择:
");
gotocxmm;
}
}
2.3按学号或姓名查询其籍贯;
/*****************************查询函数*************************/
voidhjxmselect(void)//按学号方式查询函数
{
ssmmx:
intn=0;
longhh;
system("cls");
printf("\n★★★★★欢迎使用户籍管理系统★★★★★\n");
printf("\n★★★查询编辑信息★★★\n");
printf("\n〓提示输入0返回上级菜单〓\n\n\n");
printf("请您输入学号:
");
scanf("%ld",&hh);
if(hh!
=0)
{
structhj*p;
structhj*q=NULL,*head=NULL;
fp=fopen("hj.txt","rb");
if(fp==NULL)
{
printf("\n没有记录,请输入记录然后再查询!
");
getch();
gotojjx;
}
while(!
feof(fp))
{
n++;
p=(structhj*)malloc(sizeof(structhj));
fread(p,sizeof(structhj),1,fp);
if(n==1)
head=p;
else
q->next=p;
q=p;
}
q->next=NULL;
p=head;
while(p!
=NULL)
{
if(p->number==hh)
{
inta;
printf("\n结果→学号=%ld姓名=%s",p->number,p->name);
printf("\n地址=%s",p->address);
printf("\n\n操作→⑴更改数据⑵删除数据⑶查询其他数据⑷返回上页⑸退出程序\n\n请您选择操作:
");
ssmx:
scanf("%d",&a);
switch(a)
{
voidhjedit(structhj*headd,structhj*pp);
voidhjdelete(structhj*headdd,structhj*ss);
case1:
hjedit(head,p);
gotossmmx;break;
case2:
hjdelete(head,p);
gotossmmx;break;
case3:
gotossmmx;
case4:
gotojjx;
case5:
exit(0);
default:
printf("\n错误的选择,请重新选择:
");
gotossmx;
}
}
else
p=p->next;
}
intiiii=0;
printf("\n没有此记录1.重新查询2.返回上一页3.退出程序!
");
printf("\n请选择:
");
qqqq:
scanf("%d",&iiii);
switch(iiii)
{
case1:
gotossmmx;
case2:
gotojjx;
case3:
exit(0);
default:
printf("\n错误的选择,请重新选择:
");
gotoqqqq;
}
gotojjx;
}
jjx:
;
}
voidhjxhselect(void)//按姓名方式查询函数
{
ssmm:
intn=0;
charhh[10];
system("cls");
printf("\n★★★★★欢迎使用户籍管理系统★★★★★\n");
printf("\n★★★查询编辑信息★★★\n");
printf("\n〓提示输入0返回上级菜单〓\n\n\n");
printf("请您输入姓名:
");
scanf("%s",hh);
if(strcmp(hh,"0")!
=0)
{
structhj*p;
structhj*q=NULL,*head=NULL;
fp=fopen("hj.txt","rb");
if(fp==NULL)
{
pr
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 学生 籍贯 信息 记录簿 语言 课程设计