课程设计报告---学生籍贯信息记录簿.doc
《课程设计报告---学生籍贯信息记录簿.doc》由会员分享,可在线阅读,更多相关《课程设计报告---学生籍贯信息记录簿.doc(35页珍藏版)》请在三一文库上搜索。
1、 面向过程课程设计学生籍贯信息记录簿软件院(系)别 信息工程系 班 级 电气102班 课 程 设 计 任 务 书题 目 学生籍贯信息记录簿 系 (部) 信息工程系 专 业 电气类 班 级 102班 8 月 29 日至 9 月 2 日 共 1 周指导教师(签字) 系 主 任(签字) 年 月 日1、 设计内容及要求 编制一个学生籍贯信息记录簿,每个学生信息包括:学号、姓名、籍贯。具体功能: (1)创建信息链表并以磁盘文件保存; (2)读取磁盘文件并显示输出所有学生的籍贯信息; (3)按学号或姓名查询其籍贯; (4)按籍贯查询并输出该籍贯的所有学生; (5)能添加、删除和修改学生的籍贯信息;(6)显
2、示输出四川籍和非四川籍学生的信息并可分别存盘。2、 设计原始资料 1、链表基础知识 2、文件处理基础知识三、设计完成后提交的文件和图表1计算说明书部分数据库设计分析#include#include#include#define LEN sizeof(struct Student)struct Studentchar num21;char name256;char address562;struct Student *next;int n;/n为全局变量,本文件模块中各函数均可使用它struct Student *creat()/定义函数。此函数返回一个指向链表头的指针struct Studen
3、t *head;struct Student *p1,*p2;n=0;p1=p2=(struct Student *)malloc(LEN);printf(请依次输入学生的信息,输入学号为零时退出。n);printf(请输入学生的学号:n);gets(p1-num);printf(请输入学生的姓名:n);gets(p1-name);printf(请输入学生的地址:n);gets(p1-address);head=NULL;while(p1-num0!=0)/当学号是0时,退出n=n+1;if(n=1)head=p1;elsep2-next=p1;p2=p1;p1=(struct Student
4、 *)malloc(LEN);/开辟动态存储区,把起始地址付给p1printf(请输入学生的学号:n);gets(p1-num);/输入其他学生的学号和成绩printf(请输入学生的姓名:n);gets(p1-name);printf(请输入学生的地址:n);gets(p1-address);p2-next=NULL;system(cls);return(head);void print_save(struct Student head)FILE *fp;struct Student *p;fp=fopen(D:stduent.txt,ab+);/打开文件if(fp=NULL)printf(文
5、件无法打开n);exit(0);printf(n现在,有 %d 条记录,分别是:n,n);p=&head;if(&head!=NULL)doprintf(n学号:);puts(p-num);printf(n姓名:);puts(p-name);printf(n地址:);puts(p-address);fseek(fp,0,2);if(fwrite(p,sizeof(struct Student),1,fp)!=1)printf(文件无法写入n);p=p-next;while(p!=NULL);fclose(fp);/关闭文件getchar();system(cls);struct Student
6、 *pt;/定义一个Student类型的指针char comp3;/comp为保存输入的变量int main()/一个调用这个creat函数的main函数 cvoid ShowView();/界面显示void name_surch();/按姓名查找void num_surch();/按学号查找void NativePlace_surch();/按籍贯查找void Delete_shiyan();/删除学生信息void modification_shiyan();/修改学生信息void showSzechwan_No();/分别显示四川和非四川籍学生并非别存盘void fileout(struc
7、t Student *p);/文件输出void print_save(struct Student head);while(1)ShowView();if(strnicmp(comp,1,3)=0)/strnicmp比较两个字符串的函数pt=creat();/函数返回链表第一个结点的地址else if(strnicmp(comp,6,3)=0)print_save(*pt);else if(strnicmp(comp,3,3)=0)/输出文件内容fileout(pt);else if(strnicmp(comp,2,3)=0)name_surch();else if(strnicmp(comp
8、,7,3)=0)num_surch();else if(strnicmp(comp,9,3)=0)/modification();modification_shiyan();/修改学生信息else if(strnicmp(comp,4,3)=0)/Delete();Delete_shiyan();else if(strnicmp(comp,5,3)=0)showSzechwan_No();else if(strnicmp(comp,8,3)=0)NativePlace_surch();else if(strnicmp(comp,0,3)=0)break;elseprintf(输入错误!n);g
9、etchar();system(cls);return 0;void fileout(struct Student *p)FILE *fp;printf(现在有%d条记录,分别是:n,n);fp=fopen(D:stduent.txt,rb);/0x00429af0if(fp=NULL)printf(文件无法打开n);exit(0);rewind(fp);while(!feof(fp)fread(p,sizeof(struct Student),1,fp);/从文件中读取一块数据printf(%-15s,p-num);printf(%-15s,p-name);printf(%-15s,p-ad
10、dress);puts(n);fclose(fp);getchar();system(cls);void ShowView()/主菜单printf(*n);printf(*欢迎进入学生籍贯信息记录簿*n);printf(*n);printf(*1、cin添加 *n);printf(*2、namesurch按名字搜索 *n);printf(*3、fileout显示文件中的信息 *n);printf(*4、delete删除学生信息 *n);printf(*5、showSzechwan_No分别显示四川和非四川籍学生并非别存盘 *n);printf(*6、save保存当前信息 *n);printf(
11、*7、numsurch按学号搜索 *n);printf(*8、nativeplace安籍贯查询 *n);printf(*9、modif修改学生信息 *n);printf(*0、break退出 *n);printf(*n);printf(*请输入您的选择¥:);gets(comp);system(cls);/清屏void name_surch()FILE *fp;char surch256;printf(请输入要查询的人的名字:n);gets(surch);fp=fopen(D:stduent.txt,r);/0x00429af0if(fp=NULL)printf(不能打开文件n);exit(0
12、);rewind(fp);/指向文件的开始while(!feof(fp)/查找Student a;while(!feof(fp)fread(&a,sizeof(Student),1,fp);/从p指向的文件读入一组数据if(!strcmp(a.name,surch)printf(%s,%s,%sn,a.num,a.name,a.address);break;if(!feof(fp)return;elseprintf(查无此人n);fclose(fp);getchar();system(cls);void num_surch()FILE *fp;char surch256;printf(请输入要
13、查询的人的学号:);gets(surch);fp=fopen(D:stduent.txt,rb);/0x0042aab8if(fp=NULL)printf(ERROR);exit(0);rewind(fp);/指向文件的开始while(!feof(fp)/查找Student a;while(!feof(fp)fread(&a,sizeof(Student),1,fp);/从p指向的文件读入一组数据if(!strcmp(a.num,surch)printf(%s,%s,%sn,a.num,a.name,a.address);break;if(!feof(fp)return;elseprintf(
14、查无此人n);fclose(fp);getchar();system(cls);void NativePlace_surch()/按籍贯查询FILE *fp;char surch256;printf(请输入要查询的人的籍贯:n);gets(surch);fp=fopen(D:stduent.txt,rb);/0x00429af0if(fp=NULL)printf(文件打不开n);exit(0);rewind(fp);/指向文件的开始Student a;while(!feof(fp)fread(&a,sizeof(struct Student),1,fp);/从p指向的文件读入一组数据if(!s
15、trcmp(a.address,surch)/相当于strcmp(a.address,surch)=0printf(%s,%s,%sn,a.num,a.name,a.address);if(!feof(fp)return;fclose(fp);getchar();system(cls);void showSzechwan_No()/分别显示四川和非四川籍学生并非别存盘FILE *fp;FILE *sfp;/指向四川籍学生文件sfp=fopen(D:四川stduent.txt,wb);if(sfp=NULL)printf(不能打开文件n);exit(0);FILE *ffp;/指向非四川籍学生文
16、件ffp=fopen(D:非四川stduent.txt,wb);if(ffp=NULL)/ffp=0x0042aad8printf(不能打开文件n);exit(0);fp=fopen(D:stduent.txt,rb);/0x00429af0if(fp=NULL)printf(不能打开文件n);exit(0);rewind(fp);/指向文件的开始printf(四川籍学生信息:n);Student a;while(!feof(fp)fread(&a,sizeof(struct Student),1,fp);/从p指向的文件读取一组数据if(!strcmp(a.address,四川)|!strc
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 课程设计 报告 学生 籍贯 信息 记录簿
链接地址:https://www.31doc.com/p-3292398.html