c语言学生信息管理系统链表文件的储存,学生信息管理系统(C语言基于链表文件).doc...

253b171540df25e1b84436cbe50dfc72.gif学生信息管理系统(C语言基于链表文件).doc

includestdio.hincludestdlib.hincludeconio.hincludewindows.hincludestring.hdefine LEN sizeofstruct studentdefine DAT_FILENAME Ination.txt/定义数据结构/struct dateint year;int month;int daystruct studentint ID;char Name8;int age;char xb;char telephone15;char address40;struct date birthday;char email40;struct student *next/*函数原型*/void DispMainMenu;void DisplayInationstruct student *head;struct student *FindstudentIDstruct student *head,int findID;struct student *FindstudentNamestruct student *head,char findname;struct student *Inationstruct student *head;void QueryInationstruct student *head;struct student *EditInationstruct student *head;struct student *Insertstruct student *head,struct student *p;void Savestruct student *head;struct student *Readstruct student *head;struct student *Deletestruct student *head,int findID;struct student *Addstruct student *head;void Help;/显示主菜单*/void DispMainMenuprintf*学生信息管理系统n;printfn;printftttt1信息录入n;printfn;printftttt2信息修改n;printfn;printftttt3信息查询n;printfn;printftttt4保存数据到文件n;printfn;printftttt5打开数据文件n;printfn;printftttt6文件追加n;printfn;printftttt7帮助n;printfn;printftttt0退出n;printfn;printf友情提示初次使用请先阅读帮助n;printf*n;printf请选择0-7;/*显示主菜单**帮助/void Helpprintfnttt欢迎进入帮助系统nn; printft1.请按照主菜单提示选择所需执行功能的数字代号n;printft2.所有文件请按照规范输入n;printft3.刚开始执行程序时若需要文本文件里的数据,请先进行读取文件信息n;printft4.修改信息以后,请切记需要保存n;printfn;/*显示所有学生信息/void DisplayInationstruct student *headstruct student *p;printf*;printfn学号t姓名t年龄t性别t 电话tt地址t 出生年月t emailn;pstruct student *mallocLEN;phead;ifheadNULLwhilepNULLprintf-dt-st-dt,p-ID,p-Name,p-age;printf-ct-st-st,p-xb,p-telephone,p-address;printf-d d d,p-birthday.year,p-birthday.month,p-birthday.day;printft-sn,p-email;pp-next;elseprintf无数据n;/查找指定学号的学生信息/struct student *FindstudentIDstruct student *head,int findIDstruct student *p;pstruct student *mallocLEN;phead;ifheadNULLwhilepNULLifp-IDfindIDbreak;pp-next;elseprintf无数据n;return p;/*查找指定姓名的学生信息/struct student *FindstudentNamestruct student *head,char findnamestruct student *p;pstruct student *mallocLEN;phead;ifheadNULLwhilepNULLifstrcmpp-Name,findname0break;pp-next;elseprintf无数据n;return p;/学生信息录入/struct student *Inationstruct student *headint number,i;struct student *p;pstruct student *mallocLEN;printfn请输入本次录入的学生人数;scanfd,fori0;inumber;i/*输入 number 个学生的信息*/printf请输入第d个学生的学号(八个字符以内),i1;scanfd,printfttt 姓名t;scanfs,p-Name;printfttt 年龄t;scanfd,printfttt 性别男M、女W;scanfs,printfttt 电话八位t;scanfs,p-telephone;printfttt 地址t;scanfs,p-address;printfttt 出生年月t;scanfddd,printftttemailt;scanfs,p-email;headInserthead,p;pstruct student *mallocLEN;printfn 您的输入信息是n;DisplayInationhead;returnhead;/学生信息查询*/void QueryInationstruct student *headchar select;int findID;char findname8;struct student *p;printf*请选择查询方式*n;printft1按学号查询;t2按姓名查询n;printfn;printf请选择1-2;/*显示菜单信息*/selectgetche;getch;switch selectcase1printfn 按学号查询n 请输入学生的学号;scanfd,ifpFindstudentIDhead,findIDNULL /*找到指定学号的学生*/printfn 查找结果如下n;printfn学号t姓名t年龄t性别t 电话tt地址t 出生年月t emailn;printfdtstdt,p-ID,p-Name,p-age;printfctstst,p-xb,p-telephone,p-address;printfd d d,p-birthday.year,p-birthday.month,p-birthday.day;printftsn,p-email;else /*没有找到*/printf您输入的学号不存在n;break;case2printfn 按姓名查询n 请输入学生的姓名;scanfs,ifpFindstudentNamehead,findnameNULL /*找到指定姓名的学生*/printfn 查找结果如下n;printfn 学号t 姓名t 年龄t 性别t 电话t 地址t 出生年月t emailn;printfdtstdt,p-ID,p-Name,p-age;printfctstst,p-xb,p-telephone,p-address;printfd d d,p-birthday.year,p-birthday.month,p-birthday.day;printftsn,p-email;else /*没有找到*/printf您输入的姓名不存在n;break;defaultprintf选择错误n;/*修改学生信息*/struct student *EditInationstruct student *headint findID;char select;struct student *p;printfn 请输入学生的学号;scanfd,ifpFindstudentIDhead,findIDNULL /*找到指定学号的学生*/printf*请修改方式*n;printft1修改信息;t2删除信息n;printfn;printf请选择1-2;selectgetche;getch;switch selectcase1 /*修改信息*/printf您选择的是修改信息n;printf姓 名sn,p-Name;printf原信息学号dt 年龄dt 性别cn,p-ID,p-age,p-xb;printft 电话st 地址stemailsn,p-telephone,p-address,p-email;printf请输入新信息n;printf学号t;scanfd,printf姓名t;scanfs,p-Name;printf年龄t;scanfd,printf性别男M、女W;scanfs,printf电话t;scanfs,p-telephone;printf地址t;scanfs,p-address;printf出生年月t;scanfddd,printfemailt;scanfs,p-email;break;case2 /*删除信息*/printf您选择的是删除信息n;headDeletehead,findID;break;else /*没有找到学号匹配的记录*/printf您输入的学号不存在n;return head;/有序插入*/struct student *Insertstruct student *head,struct student *pstruct student *p0,*p1;ifheadNULLheadp;p-nextNULL;returnhead;ifp-IDhead-IDp-nexthead;headp;returnhead;p1head;whilep-IDp1-IDp1-nextNULLp0p1;p1p1-next;ifp-IDp1-IDp-nextp1;p0-nextp;elseifp-IDp1-ID;elsep1-nextp;p-nextNULL;returnhead;/*保存数据到文件/void Savestruct student *headFILE *fp;struct student *p;phead;iffpDAT_FILENAME,wNULL /*以W的方式打开文件*/whilepNULLfprintffp,dt,p-ID;fprintffp,st,p-Name;fprintffp,dt,p-age;fprintffp,ct,p-xb;fprintffp,st,p-telephone;fprintffp,st,p-address;fprintffp,d d dt,p-birthday.year,p-birthday.month,p-birthday.day;fprintffp,sn,p-email;pp-next; /*将链表的内容写入文件*/fclosefp;elseprintfcannot open filen;/*打开数据文件/struct student *Readstruct student *headstruct student *p;pstruct student *mallocLEN;FILE *fp;iffpDAT_FILENAME,rNULL/*读取文件中的内容到链表中*/whilefscanffp,dt,fscanffp,dt,fscanffp,ct,fscanffp,st,p-telephone;fscanffp,st,p-address;fscanffp,d d dt,fscanffp,sn,p-email;headInserthead,p;pstruct student *mallocLEN;fclosefp;elseprintfcannot open filen;return head;/文件内容追加/struct student *Addstruct student *headheadReadhead;headInationhead;return head;/删除信息/struct student *Deletestruct student *head,int findIDstruct student *pre,*p;ifhead-IDfindIDphead;headhead-next;elseprehead; ppre-next;whilepNULLp-IDfindIDprep;pp-next;ifp-IDfindIDpre-nextp-next;freep;return head;/*主函数*/void mainchar select,c;struct student *head;headNULL;select0;whileselect0DispMainMenu;selectgetche;getch;switchselectcase0printfn您选择的是退出n;_beep300,400;continue;case1systemcls;printfn您选择的是信息录入n;headInationhead;break;case2systemcls;printfn您选择的是信息修改n;headEditInationhead;break;case3systemcls;printfn您选择的是信息查询n;QueryInationhead;break;case4systemcls;printfn您选择的是保存数据到文件n;Savehead;break;case5systemcls;printfn您选择的是打开数据文件n;ifheadReadheadNULLDisplayInationhead;break;case6systemcls;printfn您选择的是文件追加n;headAddhead;break;case7systemcls;printfn您选择的是帮助n;Help;break;defaultprintfn选择错误请重新选择n;printf请选择返回主界面或退出n; 选择是否继续printf主界面1t退出2t; scanfd,whilec1c2printf选择错误,请重新选择; printfn主界面1t退出2t; scanfd, ifc1 systemcls; else systemcls; _beep300,400; printfnt您已安全退出n; break;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值