资源描述:
《学生宿舍管理系统程序设计(优秀).docx》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、#include#include#include#include#include#includestructinformation{charname[100];//姓名chartel[100];//电话charhomenum[100];//宿舍号charnum[100];//学号charclassnum[100];//班级structinformation*next;}student;structinformation*head,*p,
2、*pr;voidtianjia();//添加新学生intchaxun();//查询学生voidshanchu();//删除学生structinformation*read(structinformation*head);voidxiugai();//修改学生voidsuoyou();//显示所有学生信息voidkongyu();//显示所有宿舍号和宿舍中空余床数voidxingming();//按姓名查找voidxuehao();//按学号查找voidsushehao();//按宿舍号查找voidbanji();//按班级查找intmain(){whi
3、le(1){system("cls");FILE*fp;intm;printf("t学生宿舍管理系统");printf("t-----------------------------------------------------");printf("t
4、1.添加新学生2.查询学生信息
5、");printf("t
6、3.删除学生信息4.修改学生信息
7、");printf("t
8、5.显示所有学生信息6.查询空余床位
9、");printf("t
10、7.退出
11、");printf("t
12、注:本系统文件保存在C:学生
13、管理系统学生信息.txt
14、");printf("t-----------------------------------------------------");printf("t请按1-7进行选择");printf("请输入数值,按回车键结束:");scanf("%d",&m);while(m<1
15、
16、m>7){printf("输入错误!!!请重新键入:");scanf("%d",&m);}switch(m)//选择语句知识点{case1:tianjia();break;case2:chaxun();break;case3:sha
17、nchu();break;case4:xiugai();break;case5:suoyou();break;case6:kongyu();break;case7:printf("退出系统......");exit(0);break;}}}voidtianjia()//添加联系人{system("CLS");FILE*fp;p=(information*)malloc(sizeof(information));fp=fopen("学生信息.txt","a");if(head==NULL)head=p;else{pr=head;while((*pr).n
18、ext!=NULL)pr=(*pr).next;(*pr).next=p;}pr=p;printf("t添加新学生信息");printf("t==============================");printf("请输入学生信息:");printf("姓名:");scanf("%s",&(*pr).name);//姓名fprintf(fp,"%4s",(*pr).name);printf("电话(11位):");scanf("%s",&(*pr).tel);//电话fprintf(fp,"%11s",(*pr).tel);pr
19、intf("宿舍号(例如:101):");scanf("%s",&(*pr).homenum);//宿舍号fprintf(fp,"%3s",(*pr).homenum);printf("学号(11位):");scanf("%s",&(*pr).num);//学号fprintf(fp,"%11s",(*pr).num);printf("班级(4位班级序号):");scanf("%s",&(*pr).classnum);//班级fprintf(fp,"%4s",(*pr).classnum);(*pr).next=NULL;fclose(fp);pri
20、ntf("按任意键返回主菜单");getch();;}voidsushehao()//按宿舍号