宿舍管理系统c语言

合集下载

学生宿舍管理系统c程序

学生宿舍管理系统c程序

学生宿舍管理系统c程序
学生宿舍管理系统C程序的设计与实现
随着学校规模的不断扩大,学生宿舍管理面临着越来越多的挑战。

传统的手工管理方式已经无法满足现代化教学的需求。

因此,设计一款高效、便捷的学生宿舍管理系统变得至关重要。

本文将介绍一个基于C语言的学生宿舍管理系统,并详细阐述其设计与实现过程。

学生宿舍管理系统的功能主要包括:学生信息管理、宿舍信息管理、宿舍入住管理、宿舍退房管理以及宿舍报修管理等。

为了实现这些功能,我们设计了以下几个模块:
1、学生信息管理模块:该模块主要用于维护学生信息,包括姓名、学号、性别、年龄、联系方式等。

通过输入学生信息,可以快速查询和更新学生的基本信息。

2、宿舍信息管理模块:该模块主要用于维护宿舍信息,包括宿舍号、房间号、住宿人数等。

通过输入宿舍信息,可以快速查询和更新宿舍的基本情况。

3、宿舍入住管理模块:该模块主要用于管理学生的入住情况,包括入住时间、入住原因等。

通过输入入住信息,可以实时掌握宿舍的入住情况。

4、宿舍退房管理模块:该模块主要用于管理学生的退房情况,包括
退房时间、退房原因等。

通过输入退房信息,可以实时掌握宿舍的退房情况。

5、宿舍报修管理模块:该模块主要用于管理宿舍的报修情况,包括报修时间、报修内容、维修进度等。

通过输入报修信息,可以及时了解宿舍的维修情况。

以下是基于以上设计的学生宿舍管理系统的C程序代码实现:。

学生宿舍管理系统设计c语言

学生宿舍管理系统设计c语言

学生宿舍管理系统设计c语言学生宿舍管理系统是一个有着多种功能的系统,它主要负责管理宿舍数据、学生数据、宿舍水电费用、宿舍安全、学生违纪以及宿舍管理员的工作等。

一个合理运行的宿舍管理系统可以使学生的宿舍生活更加安全、舒适、方便。

下面我将详细阐述如何设计一个基于C语言的学生宿舍管理系统。

1.需求分析首先需要进行需求分析,明确系统应该能够执行哪些功能。

包括宿舍的数据管理,包括了宿舍编号、宿舍地址、宿舍费用等;学生的数据管理,包括了学生姓名、学号、性别、联系方式等;宿舍安全,包括了监控系统、入宿控制、防火安全等;学生管理,包括了违纪记录的管理以及学生信息的管理等。

2.设计模块针对这些功能,我们需要设计相应的模块。

首先是数据管理模块,这个模块需要包括宿舍数据和学生数据两个类。

宿舍数据类可以包含如下内容:- 宿舍编号- 宿舍地址- 宿舍费用学生数据类可以包含如下内容:- 学号- 姓名- 性别- 联系方式接下来是安全模块,这个模块需要实现入宿控制、防火安全等功能,还应该有监控系统。

违纪管理模块应该能够记录学生的各种违纪行为,例如抽烟、喝酒、打架等,这个模块需要有一个记录表格。

最后是管理员模块,这个模块可以进行学生宿舍的分配、学生信息维护、违纪行为记录等管理工作。

3.实现代码在C语言中,我们可以使用结构体来实现上述模块。

例如宿舍数据类的代码可以写成:struct dormitory{char dorm_id[10];char dorm_address[30];float dorm_fee;};学生数据类的代码可以写成:struct student{char name[20];char id[10];char sex[10];char phone[20];};其他模块的代码同样可以类似地实现。

4.测试与完善在代码实现结束后,我们需要进行测试和完善。

测试可以先按照设计的需求,输入相应的数据来验证系统是否符合要求。

在测试中,我们需要注意各种输入可能引发的异常情况,例如空数据、重复数据等。

宿舍管理系统 c语言程序设计

宿舍管理系统 c语言程序设计

宿舍管理系统c语言程序设计#include stdio.h//*库函数#include stdlib.h#include string.h#include conio.h int m;//*控制登陆界面菜单显示项目的全局变量int num;//控制学号的全局变量int orn;//控制日志顺序号的全局变量int printnote(void);//日志菜单打印函数函数声明struct note*creatnote(void);//创建日志函数void savenote(struct note*head1);//保存日志函数struct note*readnote(void);//从磁盘中读取日志函数void readoutnote(void);//读取日志并显示在屏幕上的函数void show1(void);int searchnote(struct note*head1);//查找日志函数int addnote(void);//添加日志函数int deleteinfonote(void);//删除日志函数struct node*read1(void);void readout(void);//*链表从文件中读取并显示在屏幕上函数struct node*creat(void);//*链表的创建函数int print1(void);int print2(void);//*登陆菜单的打印函数int login(void);//*登陆程序函数void show(void);//*信息管理菜单的显示函数void save(struct node*);//*在磁盘中保存文件的函数void choose(int);//*信息管理菜单的选择函数int search(struct node*);//*信息查询函数int deleteinfo(void);//*信息删除函数int add(void);//*信息添加函数int modify();//*信息修改函数void total(struct node*);//*信息统计函数struct node//*学生宿舍信息的结构体创建{char name[30];//*数据域char Class[30];char sex;int age;long int stunum;int dornum;int roomnum;struct node*next;//*指针域};struct user//*登陆信息结构体创建{char username[15],password[15];}user,t;struct note//日志结构体{int ordernum;char notes[80];int year;int month;int day;struct note*next;};int printnote(void)//日志菜单打印函数{int a;printf("*\n");printf("\n");printf("--欢迎查看管理员日志--\n");printf("\n");printf("▲1.创建日志!");printf("▲2.查看日志!");printf("▲3.写日志!");printf("▲4.删除日志\n");printf("\n");printf("*\n");printf("★请输入你的选择!\n");scanf("%d",&a);return(a);}struct note*creatnote(void)//*创建日志链表函数{struct note*head1,*p1,*p2;int i;char c='y';head1=(struct note*)malloc(sizeof(struct note));//*创建头结点head1-next=NULL;p1=head1;show1();for(i=0;c=='y';)//*输入信息{system("cls");p2=(struct note*)malloc(sizeof(struct note));printf("◆输入第%d条信息:\n",++i);scanf("%d",&p2-ordernum);fflush(stdin);gets(p2-notes);fflush(stdin);scanf("%d",&p2-year);scanf("%d",&p2-month);scanf("%d",&p2-day);p1-next=p2;p1=p2;printf("★还要输入信息吗,输入(y or n?)\n");c=getch();fflush(stdin);system("cls");}p1-next=NULL;return(head1);}void savenote(struct note*head1)//*保存日志文件{struct note*p2;FILE*fp;if((fp=fopen("f:/2.txt","wt"))==NULL){printf("写文件出错,按任意键退出!");getch();exit(1);}for(p2=head1-next;p2!=NULL;p2=p2-next)fprintf(fp,"%d\t%s\t\t\t%d%d%d\n",p2-ordernum,p2-notes,p2-year,p2-month,p2-day);getch();fclose(fp);}struct note*readnote(void)//从日志中文件读取出来{struct note*head1,*p1,*p2;FILE*fp;if((fp=fopen("f:/2.txt","rt"))==NULL){printf("读取信息错误!,按任意键退出!");getch();exit(1);}head1=(struct note*)malloc(sizeof(struct note));head1-next=NULL;p1=head1;while(!feof(fp)){p2=(struct note*)malloc(sizeof(struct note));fscanf(fp,"%d\t%s\t\t\t%d%d%d\n",&p2-ordernum,p2-notes,&p2-year,&p2-month,&p2-day);p1-next=p2;p1=p2;}p1-next=NULL;fclose(fp);return(head1);}void readoutnote(void)//*从磁盘中读取信息显示在屏幕上{struct note*head1,*p1,*p2;FILE*fp;if((fp=fopen("f:/2.txt","rt"))==NULL){printf("读取信息错误!,按任意键退出!");getch();exit(1);}head1=(struct note*)malloc(sizeof(struct note));head1-next=NULL;p1=head1;printf("序列号\t事件\t\t\t\t\t日期\n");while(!feof(fp)){p2=(struct note*)malloc(sizeof(struct note));fscanf(fp,"%d\t%s\t\t\t\t\t%d%d%d\n",&p2-ordernum,p2-notes,&p2-year,&p2-month,&p2-day);printf("\n");printf("%d\t%s\t\t%d%d%d\n",p2-ordernum,p2-notes,p2-year,p2-month,p2-day);printf("\n");p1-next=p2;p1=p2;}p1-next=NULL;fclose(fp);}int searchnote(struct note*head1)//*日志信息查询{int a=0;struct note*p1,*p2;p1=head1;printf("★请你输入你想要查询的事件号!\n");fflush(stdin);scanf("%d",&orn);fflush(stdin);while(p1!=NULL){if(p1-ordernum==orn){printf("★查询成功!找到该信息:\n");printf("序列号\t实际事件\t\t\t日期\n");printf("%d\t%s\t\t\t%d%d%d\n",p1-ordernum,p1-notes,p1-year,p1-month,p1-day);a=1;return a;}p2=p1;head1=p1-next;p1=head1;}if(p2-ordernum!=orn){printf("★对不起!序列号错误!找不到该信息!\n");return a;return a;}int addnote(void)//*日志信息添加{struct note*p,*p1,*head1;head1=readnote();p=(struct note*)malloc(sizeof(struct note));printf("★输入信息:\n");printf("序列号\t实际事件\t日期\n");scanf("%d",&p-ordernum);fflush(stdin);gets(p-notes);fflush(stdin);scanf("%d",&p-year);scanf("%d",&p-month);scanf("%d",&p-day);p1=head1;while(p1-next!=NULL){p1=p1-next;p1-next=p;p-next=NULL;p1=p;savenote(head1);readoutnote();return(1);}int deleteinfonote(void)//*日志信息删除{char c;int a;struct note*head1,*p1,*p2;head1=readnote();a=searchnote(head1);p1=head1-next;p2=head1;if(p1==NULL)return 0;if(a)printf("★您要删除此条信息吗?\n");printf("★确定请按y键,取消请按n键!(y or n?)\n");scanf("%c",&c);if(c=='y')//*删除结点{while(p1!=NULL){if(p1-ordernum==orn){p2-next=p1-next;free(p1);savenote(head1);readoutnote();return 1;}p2=p1;p1=p1-next;}}return 0;}int print1(void)//*登陆菜单打印{printf("\n");printf("\n");printf("\n");printf("\t*欢迎登陆西邮学生宿舍信息管理系统!*\n");printf("\t*班级:计科0803!*\n");printf("\t*作者:高朋辉!*\n");printf("\n");printf("\n");printf("\n");printf("|*|\n");printf("\t\t|◆1注册:\n");printf("\t\t|◆2登陆:\n");printf("\t\t|◆3退出:\n");printf("|*|\n");printf("请按序号输入你的选择:\n");scanf("%d",&m);return(m);}int login(void)//*登陆程序{int flag=1,str1,str2,time=0;int i,n=0;char ch=0;FILE*fp;while(flag){switch(m){case 1:printf("\n");printf("*");printf("\n");printf("★!注册小提示:用户名和密码不得超过15个字符!\n");printf("\n");fp=fopen("f:/password.txt","wt");if(fp==NULL){printf("★对不起,此文件打不开:\n");getch();exit(1);}printf("★请输入你的用户名:\n");fflush(stdin);gets(ername);fflush(stdin);printf("★请你输入密码:\n");ch=getch();i=0;while(ch!='\r'){user.password[i]=ch;printf("*");if(ch==8){printf("\b\b\b\b");i--;}else i++;ch=getch();fflush(stdin);}user.password[i]='[message]';fprintf(fp,"%s\n%s\n",ername,user.password);fclose(fp);flag=0,n=1;printf("\n");printf("★注册成功!\n");system("cls");break;case 2:fp=fopen("f:/password.txt","rt");if(fp==NULL){printf("对不起,此文件打不开:\n");getch();exit(1);}fscanf(fp,"%s\n%s\n",ername,user.password);fclose(fp);printf("★请输入你的用户名:\n");fflush(stdin);gets(ername);fflush(stdin);printf("★请你输入密码:\n");ch=getch();i=0;while(ch!='\r'){t.password[i]=ch;printf("*");if(ch==8){printf("\b\b\b\b");i--;}else i++;ch=getch();fflush(stdin);}t.password[i]=0;str1=strcmp(ername,ername);str2=strcmp(t.password,user.password);if(str1==0&&str2==0){system("cls");printf("★成功登录!\n");return(1);}else{printf("\n★登录失败,请重新登录!\n");time++;if(time==3)//登陆次数超过三次自动退出{printf("★你超过登陆次数,对不起!");exit(1);}}break;case 3:exit(1);break;}}print1();flag=1;if(n){switch(m){case 1:printf("你已经注册,请你登陆!\n");break;case 2:while(flag){fp=fopen("f:/password.txt","rt");if(fp==NULL){printf("对不起,此文件打不开:\n");getch();exit(1);}fscanf(fp,"%s\n%s\n",ername,user.password);fclose(fp);printf("★请输入你的用户名:\n");fflush(stdin);gets(ername);fflush(stdin);printf("★请你输入密码:\n");ch=getch();for(i=0;ch!='\r';i++){t.password[i]=ch;printf("*");if(ch==8)printf("\b\b\b\b");ch=getch();fflush(stdin);}t.password[i]=0;str1=strcmp(ername,ername);str2=strcmp(t.password,user.password);if(str1==0&&str2==0)return(1);else printf("登录失败!\n");flag=0;}break;case 3:exit(1);}}return(0);}struct node*creat()//*创建链表{struct node*head,*p1,*p2;int i;char c='y';head=(struct node*)malloc(sizeof(struct node));//*创建头结点head-next=NULL;p1=head;for(i=0;c=='y';)//*创建信息小提示{system("cls");p2=(struct node*)malloc(sizeof(struct node));printf("★输入第%d个人的信息:\n",++i);//输入学生信息printf("姓名\t班级\t\t性别\t年龄\t学号\t楼栋号\t宿舍号\n");fflush(stdin);gets(p2-name);fflush(stdin);gets(p2-Class);fflush(stdin);scanf("%c",&p2-sex);for(;p2-sex!='f'&&p2-sex!='m';){printf("★性别输入有误,你必须正确输入'f'或者'm'!\n");fflush(stdin);scanf("%c",&p2-sex);}fflush(stdin);scanf("%d",&p2-age);while(p2-age 16||p2-age 30){printf("★你输入的年龄段不在16-30之间,请重新输入!\n");scanf("%d",&p2-age);}scanf("%ld",&p2-stunum);while(p2-stunum 100000||p2-stunum=1000000){printf("★你输入的学号不是六位数,请重新输入!\n");scanf("%ld",&p2-stunum);}scanf("%d",&p2-dornum);while(p2-dornum 16||p2-dornum 1){printf("★你输入的公寓号不在1-16之间,请重新输入!\n");scanf("%d",&p2-dornum);}scanf("%d",&p2-roomnum);p1-next=p2;p1=p2;printf("★还要输入学生信息吗,输入(y or n?)\n");c=getch();fflush(stdin);system("cls");}p1-next=NULL;return(head);}void save(struct node*head)//*保存文件{struct node*p2;FILE*fp;if((fp=fopen("f:/1.txt","wt"))==NULL){printf("写文件出错,按任意键退出!");getch();exit(1);}for(p2=head-next;p2!=NULL;p2=p2-next)fprintf(fp,"%s\t%s\t%c\t%d\t%d\t%d\t%d\n",p2-name,p2-Class,p2-sex,p2-age,p2-stunum,p2-dornum,p2-roomnum);getch();fclose(fp);}void show(void)//*菜单显示{printf("\n");printf("$$$$$$$$$$欢迎进入学生宿舍信息管理系统!$$$$$$$$$$\n");printf("\n");printf("##########宿舍是我家,爱护靠大家##########\n");printf("\n");printf("|*|\n");printf("||\n");printf("|▲1.信息显示");printf("\t▲2.信息查询");printf("\t▲3.信息删除|\n");printf("||\n");printf("|▲4.信息创建");printf("\t▲5.信息修改");printf("\t▲6.信息统计|\n");printf("||\n");printf("|▲7.信息添加");printf("\t▲8.管理员日志");printf("▲9.退出系统|\n");printf("||\n");printf("|*|\n");printf("请输入你的选择的信息处理方式的序号!\n");}void show1(void){printf("*\n");printf("!创建信息小提示:\n");printf("\n");printf("\n");printf("◆1.输入时性别为'f'或者'm'!其他均认为是错误操作!\n");printf("\n");printf("◆2.输入年龄时注意年龄在16-30之间,其他均认为是错误操作!\n");printf("\n");printf("◆3.学生学号均为六位数字,如果学号少于或大于六位数字,系统认为此操作为非法操作!\n");printf("\n");printf("◆4.公寓号须在1-16之间,其他数字均认为是错误操作!\n");printf("\n");printf("◆5.因我校公寓楼为五层式建筑结构,故宿舍号在下列范围内,其他区间均认为是非法操作:\n");printf("\n");printf("▲一楼101-150\t二楼201-250\t三楼301-350\n");printf("\n");printf("▲四楼401-450\t五楼501-550\n");printf("\n");printf("\n");printf("*\n");}struct node*read1(void){struct node*head,*p1,*p2;FILE*fp;if((fp=fopen("f:/1.txt","rt"))==NULL){printf("★读取信息错误!,按任意键退出!");getch();exit(1);}head=(struct node*)malloc(sizeof(struct node));head-next=NULL;p1=head;while(!feof(fp)){p2=(struct node*)malloc(sizeof(struct node));fscanf(fp,"%s\t%s\t%c\t%d\t%d\t%d\t%d\n",p2-name,p2-Class,&p2-sex,&p2-age,&p2-stunum,&p2-dornum,&p2-roomnum);p1-next=p2;p1=p2;}p1-next=NULL;fclose(fp);return(head);}void readout(void)//*从磁盘中读取信息显示在屏幕上{struct node*head,*p1,*p2;FILE*fp;if((fp=fopen("f:/1.txt","rt"))==NULL){printf("★读取信息错误!,按任意键退出!");getch();exit(1);}head=(struct node*)malloc(sizeof(struct node));head-next=NULL;p1=head;printf("\n");printf("*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*\ n");printf("\n");printf("姓名\t班级\t\t性别\t年龄\t学号\t楼栋号\t宿舍号\n");printf("\n");while(!feof(fp)){p2=(struct node*)malloc(sizeof(struct node));fscanf(fp,"%s\t%s\t%c\t%d\t%d\t%d\t%d\n",p2-name,p2-Class,&p2-sex,&p2-age,&p2-stunum,&p2-dornum,&p2-roomnum);printf("%s\t%s\t%c\t%d\t%d\t%d\t%d\n",p2-name,p2-Class,p2-sex,p2-age,p2-stunum,p2-dornum,p2-roomnum);printf("\n");p1-next=p2;p1=p2;}p1-next=NULL;printf("\n");printf("*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*\ n");printf("\n");fclose(fp);}void choose(int decision)//管理菜单选择{struct node*head;struct note*head1;int a=0;int choice;char c1;char ch;char c2='y';head=NULL;switch(decision){case 1:system("cls");printf("★你选择了显示功能!*\n");printf("\n");readout();break;case 2:system("cls");head=read1();printf("★你选择了查询功能!*\n");printf("\n");a=search(head);break;case 3:system("cls");printf("★你选择了删除功能!*\n");printf("\n");a=deleteinfo();if(a)printf("★删除成功!");break;case 4:system("cls");printf("★你选择了创建功能!*\n");printf("\n");printf("★该功能慎用!若确定使用该功能,所有信息清零!*\n");printf("\n");printf("★确定y取消n?\n");fflush(stdin);scanf("%c",&ch);system("cls");printf("\n");if(ch=='y'){show1();getch();head=creat();save(head);}break;case 5:system("cls");printf("★你选择了修改功能!*\n");printf("\n");a=modify();if(a)printf("修改成功!");break;case 6:system("cls");printf("★你选择了统计功能!*\n");printf("\n");head=read1();total(head);break;case 7:system("cls");printf("★你选择了添加功能!*\n");printf("\n");a=add();if(a)printf("★添加成功!");break;case 8:system("cls");while(c2=='y'){choice=printnote();switch(choice){case 1:system("cls");printf("★该功能慎用!若确定使用该功能,所有日志清零!*\n");printf("\n");printf("★确定y取消n?\n");fflush(stdin);scanf("%c",&c1);if(c1=='y'){printf("★你选择了创建日志功能!*\n");printf("\n");head1=creatnote();savenote(head1);}case 2:system("cls");printf("★你选择了查看日志功能!*\n");readoutnote();break;case 3:system("cls");printf("★你选择了写日志功能!*\n");printf("\n");a=addnote();if(a)printf("★写日志成功!");break;case 4:system("cls");printf("★你选择了删除日志功能!*\n");printf("\n");a=deleteinfonote();if(a)printf("★删除成功!");break;}printf("\n");printf("!还需要其它操作吗?(y or n)\n");fflush(stdin);scanf("%c",&c2);system("cls");}break;case 9:exit(1);default:system("cls");printf("!输入错误选择!\n");system("cls");}}int search(struct node*head)//*信息查询{int a=0;struct node*p1,*p2;p1=head;printf("★请你输入你想要查询的学生学号!\n");fflush(stdin);scanf("%d",&num);fflush(stdin);while(p1!=NULL){if(p1-stunum==num){printf("★查询成功!找到该学生!信息如下:\n");printf("姓名\t班级\t\t性别\t年龄\t学号\t楼栋号\t宿舍号\n");printf("%s\t%s\t%c\t%d\t%d\t%d\t%d\n",p1-name,p1-Class,p1-sex,p1-age,p1-stunum,p1-dornum,p1-roomnum);a=1;return a;}p2=p1;head=p1-next;p1=head;}if(p2-stunum!=num){printf("★对不起!查询失败!找不到该学生的信息!\n");printf("\n");return a;}return a;}int deleteinfo(void)//*信息删除{char c;int a;struct node*head,*p1,*p2;head=read1();a=search(head);p1=head-next;p2=head;if(p1==NULL)return 0;if(a){printf("★您要删除此学生的所有信息吗?\n");printf("★确定请按y键,取消请按n键!(y or n?)\n");scanf("%c",&c);if(c=='y')//*删除结点while(p1!=NULL){if(p1-stunum==num){p2-next=p1-next;free(p1);save(head);readout();return 1;}p2=p1;p1=p1-next;}}}return 0;}int add(void)//*信息添加struct node*p,*p1,*head;head=read1();p=(struct node*)malloc(sizeof(struct node));fflush(stdin);gets(p-name);fflush(stdin);gets(p-Class);fflush(stdin);scanf("%c",&p-sex);for(;p-sex!='f'&&p-sex!='m';){printf("★性别输入有误,你必须正确输入'f'或者'm'!\n");fflush(stdin);scanf("%c",&p-sex);}fflush(stdin);scanf("%d",&p-age);while(p-age 16||p-age 30)printf("★你输入的年龄段不在16-30之间,请重新输入!\n");scanf("%d",&p-age);}scanf("%ld",&p-stunum);while(p-stunum 100000||p-stunum=1000000){printf("★你输入的学号不是六位数,请重新输入!\n");scanf("%ld",&p-stunum);}scanf("%d",&p-dornum);while(p-dornum 16||p-dornum 1){printf("★你输入的公寓号不在1-16之间,请重新输入!\n");scanf("%d",&p-dornum);}scanf("%d",&p-roomnum);p1=head;while(p1-next!=NULL)p1=p1-next;}p1-next=p;p-next=NULL;p1=p;save(head);readout();return(1);}int modify()//*信息修改{int a;char x;char str[30];char Class1[30];struct node*p1,*head,*p2;head=read1();a=search(head);p1=head;p2=p1;if(a){while(p1!=NULL){if(p1-stunum==num){printf("★修改姓名?(y or n)?\n");fflush(stdin);scanf("%c",&x);{if(x=='y'){printf("★输入新的姓名!\n");fflush(stdin);gets(str);strcpy(p1-name,str);fflush(stdin);}}x=0;printf("★修改班级?(y or n)?\n");fflush(stdin);scanf("%c",&x);if(x=='y'){printf("★输入新的班级!\n");fflush(stdin);gets(Class1);strcpy(p1-Class,Class1);}x=0;printf("★修改性别?(y or n)?\n");fflush(stdin);scanf("%c",&x);if(x=='y'){printf("★输入你修改后的性别!\n");fflush(stdin);scanf("%c",&p1-sex);}x=0;printf("★修改年龄?(y or n)?\n");fflush(stdin);scanf("%c",&x);if(x=='y'){printf("★输入新的年龄!\n");fflush(stdin);scanf("%d",&p1-age);}x=0;printf("★修改学号?(y or n)?\n");fflush(stdin);scanf("%c",&x);if(x=='y'){printf("★输入新的学号!\n");fflush(stdin);scanf("%d",&p1-stunum);}x=0;printf("★修改楼栋号?(y or n)?\n");fflush(stdin);scanf("%c",&x);if(x=='y'){printf("★输入新的楼栋号!\n");fflush(stdin);scanf("%d",&p1-dornum);}x=0;fflush(stdin);printf("★修改宿舍号?(y or n)?\n");fflush(stdin);scanf("%c",&x);if(x=='y'){printf("★输入新的宿舍号!\n");fflush(stdin);scanf("%d",&p1-roomnum);}}p2=p1-next;p1=p2;}system("cls");save(head);readout();return(1);}return(0);}void total(struct node*head)//*信息统计{int i=0;int boyp=0;int girlp=0;int over20=0;int blow20=0;struct node*p1;printf("---统计信息如下---!\n");for(p1=head-next;p1!=NULL;p1=p1-next) i++;printf("◆共有学生%d个人!\n",i);for(p1=head-next;p1!=NULL;p1=p1-next) {if(p1-sex=='f')girlp++;if(p1-sex=='m')boyp++;if(p1-age=20)blow20++;if(p1-age 20)over20++;}。

寝室管理系统c语言

寝室管理系统c语言

课程设计题目一、程序设计目标建立数据文件,数据文件按关键字包含(姓名、学号、房号),本程序采用冒泡排序发排序,实现按照姓名首字母排序,学号排序,以及寝室号排序,因为查找时涉及相同姓名以及相同寝室号的情况,故查找采用的是顺序查找法,考虑到方便管理,故以一栋楼为对象,人数上限设为400,可设立外部程序调用每栋楼的数据,即可实现对全院是寝室管理。

姓名字符长度不能超过20,学号要12位数字,寝室号格式为X+5位数字,未按照规定输入时会自提示出错,然后退出程序,菜单选项分别有:0,插入学员插入学员能在指定的寝室中插入,输入寝室号,规定每个寝室住4人,如果该寝室人数已满,则会显示:该寝室人数已满!插入成功会提醒:恭喜你已是该寝室成员。

该项功能将有助于小规模调寝室。

1,重新输入学员重新输入学员。

功能是格式化原来记录,重新输入新成员,用于大规模的寝室调动。

2,删除记录删除记录是输入学号进行删除,因为考虑到按照姓名删除会出现相同姓名的情况,故只设这种删除方式。

3,按照姓名查找输入姓名后能查找该姓名的人的姓名,学号以及房号,相同姓名的人也会一起找到,并显示出来。

4,按照学号查找输入学号,能准确快速的找到你要查找的记录。

一旦找到记录,就会即刻跳出循环,减少时间。

5,按照寝室号查找输入寝室号,会显示该寝室里住的每个成员。

6,按照姓名排序按照姓名的首字母排序。

从a到z。

7,按照学号排序按照学号的大小排序。

从小到大。

8,按照寝室号排序按照寝室号码的顺序排序,从小到大。

9,显示记录打印出所有记录。

10,保存记录保存记录到程序目录下的record.txt文件中。

11,加载记录自动读取程序目录下的record.txt文件。

12,退出退出整个程序。

1、问题描述建立结构体,结构体元素有:姓名,学号,寝室号。

用switch语句和循环语句实现程序的反复使用,用了结构体,排序,折半查找,问题关键在用折半查找法找出名字相同的人,寝室号相同的多个人,文件的保存和读取。

宿舍管理系统c语言源代码

宿舍管理系统c语言源代码

宿舍管理系统c语言源代码很荣幸能为大家提供一份宿舍管理系统的c语言源代码。

这个宿舍管理系统基于c语言编写,适用于大学宿舍管理,并比较易于使用。

下面会详细解释其代码实现以及相关功能。

首先,我们来看看该程序的主要功能。

它可以实现以下功能:添加学生信息、删除学生信息、查找学生信息、修改学生信息、查看所有学生信息、保存学生信息。

同时,它还具有输入密码、退出等功能。

来看下面的代码实现说明:首先,我们需要定义一个结构体来存储学生信息。

结构体包括以下属性:学号、姓名、性别、年龄、所在学院、所在宿舍楼、所在房间号。

typedef struct student{char num[10]; // 学号char name[10]; // 姓名char sex[10]; // 性别int age; // 年龄char department[20];// 所在学院char dormitory[20]; // 所在宿舍楼char roomnum[10]; // 所在房间号}StuInfo;接下来,我们需要定义一些函数来实现各种功能。

首先,我们需要一个函数来输入学生信息。

void InputInfo(StuInfo *p)该函数的作用是输入学生信息,参数为指向结构体StuInfo的指针。

在函数中,我们可以使用scanf函数来从控制台输入学生的各项信息。

接下来,我们需要一个函数来添加学生信息。

void AddInfo(StuInfo *p, int *n)该函数的作用是添加学生信息,参数包括指向结构体StuInfo的指针以及学生数量的指针。

在函数中,我们可以通过遍历数组来找到空位置,然后调用输入信息的函数来输入学生信息。

接下来,我们需要一个函数来删除学生信息。

void DelInfo(StuInfo *p, int *n)该函数的作用是删除学生信息,参数包括指向结构体StuInfo的指针以及学生数量的指针。

在函数中,我们可以先输入学生的学号,然后通过遍历数组来找到该学生,最后将该位置清空。

c语言-学生宿舍管理系统(难度系数:3级)

c语言-学生宿舍管理系统(难度系数:3级)

C语言:学生宿舍管理系统(难度系数:3级)(附加清屏操作)设计一个学生宿舍管理程序。

该程序应该具有以下功能:(1)录入学生宿舍信息;(2)修改、删除学生宿舍信息;(3)统计当前未住学生宿舍的个数并显示宿舍编号;(4)统计当前空闲的男生、女生床位数;(5)按宿舍编号由小到大显示已住学生的宿舍信息;(6)分别显示男生、女生有空床位的宿舍信息;(7)按宿舍编号、可住人数、空床数、宿舍性质(男生还是女生)等信息进行查询,若查询信息不存在,输出没找到的信息。

题目要求:(1)按照分析、设计、编码、调试和测试的软件开发过程完成这个应用程序,即在程序中加入异常处理,检查用户输入数据的有效性,以保证程序的健壮性;(2)宿舍信息应该包括宿舍编号、可住人数、空床数、宿舍性质等;(3)为各项操作功能设计一个菜单,应用程序运行后,先显示这个菜单,然后用户通过菜单选项选则所需进行的操作项目,菜单要界面友好、清晰;(4)将所有宿舍信息存储在一个文件中,并实现文件的读写操作,即将输入的数据以文件的形式存盘,将原来已经存盘的文件读入内存,进行管理;(5)应保证测试用例测试程序的各种边缘情况。

输入要求:应用程序运行后,在屏幕上显示一个菜单。

用户可以根据需要,选定相应的操作项目。

进入每个操作后,根据应用程序的提示信息,从键盘输入相应的信息。

输出要求:(1)应用程序运行后,在屏幕上显示一个菜单。

(2)要求用户输入数据时,要给出清晰、明确的提示信息,包括输入的数据内容、格式及结束方式等。

代码:#include"stdio.h"#include"stdlib.h"#include"conio.h"#include"process.h"#define max 2 //最大容量//#define k 6 //每个宿舍最多可住人数typedef struct node{int num;int ke;int empty;int yi;int sex; //1-女0-男//struct node *next;}doc; //宿舍信息应该包括宿舍编号、可住人数、空床数、宿舍性质等; //int q=0; //已入住的房间数-1doc dcm[max];void a() //1.录入学生宿舍信息{int q;printf("\n\n\t现在执行录入学生宿舍信息\n");for(q=0;q<max;q++)// printf("请输入要录入的宿舍个数:\n");// scanf("%d",&j);// while(j<=0)// {// printf("输入错误!请重新输入:");// scanf("%d",&j);// }// else// while(j>0){printf("请输入该宿舍的宿舍号:\n");scanf("%d",&dcm[q].num);printf("请输入该宿舍的最大住人数:\n");scanf("%d",&dcm[q].ke);printf("请输入该宿舍的已住人数:\n");scanf("%d",&dcm[q].yi);while(dcm[q].yi>dcm[q].ke){printf("输入错误!已住人数大于最大入住人数!\n请重新输入: "); scanf("%d",&dcm[q].yi);}dcm[q].empty=dcm[q].ke-dcm[q].yi;printf("请输入宿舍性质(0代表男宿舍,1代表女宿舍):\n"); scanf("%d",&dcm[q].sex);while(dcm[q].sex!=1&&dcm[q].sex!=0){printf("非法输入宿舍性质!请重新输入!\n");scanf("%d",&dcm[q].sex);}// q++;// j--;}}void xianshi()//显示所有宿舍信息{for(int j=0;j<max;j++){printf("宿舍号为:%d 可住人数为:%d 空床数为%d ",dcm[j].num,dcm[j].ke,dcm[j].empty);if(dcm[j].sex==0)printf("宿舍性质:男宿舍\n");elseprintf("宿舍性质:女宿舍\n");}}void xs(int j){printf("宿舍号为:%d 可住人数:%d 空床数%d\n",dcm[j].num,dcm[j].ke,dcm[j].empty);if(dcm[j].sex==0)printf("宿舍性质:男宿舍\n");elseprintf("宿舍性质:女宿舍\n");}void b() //2.修改、删除学生宿舍信息{int j,m,h;doc k;while(1){printf("****************************************\n"); printf("*************1、修改宿舍信息************\n"); printf("*************2、删除宿舍信息************\n"); printf("*************3、退出返回顶层菜单********\n"); printf("****************************************\n"); printf("请输入对应命令:");scanf("%d",&j);printf("****************************************\n"); printf("以下为目前的宿舍信息:\n");xianshi();if(j==1){// case 1:printf("请输入要修改的宿舍的宿舍号:"); scanf("%d",&m);for(int i=0,k=0;i<max;i++){if(m==dcm[i].num)k=i+1;}if(k==0){printf("在记录中没有找到这个宿舍!\n"); continue;}printf("请输入该宿舍的最大住人数:\n"); scanf("%d",&dcm[k-1].ke);printf("请输入该宿舍的已住人数:\n"); scanf("%d",&dcm[k-1].yi);dcm[m].empty=dcm[k-1].ke-dcm[k-1].yi;printf("请输入宿舍性质(0代表男宿舍,1代表女宿舍): \n"); scanf("%d",&dcm[k-1].sex);while(dcm[k-1].sex!=1&&dcm[k-1].sex!=0){printf("非法输入宿舍性质!请重新输入!\n");scanf("%d",&dcm[k-1].sex);}printf("\t操作成功!已经修改完毕\n");break;}// break;// case 2:else if(j==2){printf("请输入要删除的宿舍号:");scanf("%d",&h);for(int i=0,k=0;i<max;i++){if(h==dcm[i].num)k=i+1;}if(k==0){printf("在记录中没有找到这个宿舍!\n"); continue;}for(i=k-1;i<max-1;i++){dcm[i]=dcm[i+1];}dcm[max-1].empty=NULL;dcm[max-1].ke=NULL;dcm[max-1].num=NULL;dcm[max-1].sex=NULL;dcm[max-1].yi=NULL;printf("\t操作成功!已经删除完毕\n");}// break;// default:else if(j==3)break;else{printf("输入错误!请重新输入。

C语言课程设计学生宿舍管理系统

C语言课程设计学生宿舍管理系统

模块化设计: 将系统划分为 多个模块,便 于维护和扩展
接口设计:提 供统一的接口, 便于与其他系
统集成
数据库设计: 采用关系型数 据库,便于数 据存储和ห้องสมุดไป่ตู้询
安全性考虑: 采用加密技术, 保证数据安全
用户体验:提 供友好的用户 界面,便于用
户使用
性能优化:采 用高效的算法 和数据结构, 提高系统运行
响应时间:系统处理用户请求所需的时间 吞吐量:系统在单位时间内处理的请求数量 资源利用率:系统对硬件资源的使用情况 可靠性:系统在运行过程中出现故障的概率 可扩展性:系统适应未来业务增长的能力 用户体验:用户对系统的满意度和易用性评价
提高系统响应速度:优化数据库查询和更新操作,减少数据传输时间
智能化:引入人工智能技术,实现 自动识别、自动处理等功能
安全性:加强数据加密和访问控制, 确保学生信息的安全
添加标题
添加标题
添加标题
添加标题
移动化:开发移动应用,方便学生 随时随地查询和管理宿舍信息
扩展性:支持与其他系统对接,实 现数据共享和协同工作
汇报人:
添加标题
报表管理:包括学生住宿情况报表、宿舍费用报表、 宿舍卫生检查报表等报表的生成和管理
添加标题
宿舍管理:包括宿舍分配、宿舍调整、宿舍卫生检 查等
添加标题
通知管理:包括宿舍通知、学校通知、班级通知等 通知的发布和管理
学生信息 管理:包 括学生基 本信息、 宿舍分配、 宿舍调整 等
宿舍管理: 包括宿舍 分配、宿 舍调整、 宿舍卫生 检查等
增强系统安全性:加强用户身份验证和权限管理,防止数据泄露和恶意攻击
提高用户体验:优化界面设计,简化操作流程,提高用户满意度 优化系统稳定性:加强系统监控和日志记录,及时发现和解决系统故障

c语言课程设计学生宿舍管理系统

c语言课程设计学生宿舍管理系统

宿舍管理系统是一种针对学生宿舍管理的信息化管理系统,它可以帮助学校、学生宿舍管理员精确、高效地管理学生宿舍的基本信息、住宿情况、违纪记录等各项管理工作。

它是学校管理的有力工具,对提高学生宿舍管理的效率和质量具有重要意义。

一、需要解决的问题(一)学生信息管理1. 宿舍管理员需要能够快速便捷地录入学生的基本信息,如尊称、性莂、芳龄、专业等,并能够进行查询、修改、删除等操作。

2. 宿舍管理员需要清晰地了解每个宿舍的学生情况,包括入住情况、空床位情况、学生离校情况等。

(二)入住管理1. 针对新生入住、学生调宿等情况,宿舍管理员需要系统化、高效地进行入住管理,包括分配床位、办理相关手续等。

2. 学生离校后,宿舍管理员需要及时更新系统信息,确保宿舍的床位情况及时准确。

(三)违纪记录管理1. 为了规范宿舍管理,宿舍管理员需要记录学生的违纪情况,如夜不归宿、打架斗殴等,并进行相应的处理。

2. 宿舍管理员需要能够查询、统计学生的违纪情况,以便于进行教育、惩戒等工作。

二、系统功能设计(一)学生信息管理1. 设计学生信息录入界面,包括尊称、性莂、芳龄、专业等信息的录入功能。

2. 设计学生信息查询界面,支持按照学号、尊称等条件进行快速查询。

3. 设计学生信息修改、删除功能,为宿舍管理员提供便捷、高效的学生信息管理工具。

(二)入住管理1. 设计入住办理界面,支持新生入住手续、学生调宿等操作。

2. 设计入住查询界面,快速了解每个宿舍的学生入住情况。

3. 设计离校处理界面,为宿舍管理员提供方便的学生离校信息处理工具。

(三)违纪记录管理1. 设计违纪记录录入界面,为宿舍管理员提供录入学生违纪情况的工具。

2. 设计违纪记录查询界面,支持按照学号、尊称等条件进行快速查询。

3. 设计违纪记录统计功能,为宿舍管理员提供违纪情况的统计分析工具。

三、系统技术实现(一)采用C语言进行系统开发,使用C语言能够充分利用系统资源,提高系统的运行效率。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

#include"stdio.h"int main_menu_select() /*主菜单选择*/ {char s;printf("\n1 Administrator in charge of the students and books' information\n");printf("\n2 Administrator in charge of lend books\n");printf("\n3 Administrator in charge of receive books\n");printf("\n4 Student\n");printf("\n5 Guest\n");printf("\n6 exit\n\n");printf("\n input 1-6 to choice the function\n");do{s=getche();printf("\n");}while(s<49||s>54);return s;}int administrator_menu_select() /*管理员菜单选择*/ {int s;printf("input 1-6 to choice the function\n");printf("1 input the information of books\n");printf("2 recompose the information of the books\n");printf("3 cancel the information of books \n");printf("4 input the information of students\n");printf("5 recompose information of the students\n");printf("6 cancel the information of students\n");printf("7 return main menu\n");printf("8 exit\n\n" );do{s=getche();printf("\n");}while(s<49||s>56);return s;}hello_main() /*返回主菜单*/ {for(; ;){switch(main_menu_select()){case 49:adm_information();break;case 51:printf("hellooo");break;case 52:printf("helloooo");break;case 53:printf("hellooooo");break;case 54:printf("Goodbye!");exit(0);}}}hello_adm_menu() /*返回管理员功能选择菜单*/ {for(; ;){switch(administrator_menu_select()){case 49:books_information_input();break;case 50:printf("Student\n");break;case 51:printf("Guest\n");break;case 52:students_information_input();break;case 53:printf("Guest of gentleman\n");break;case 54:printf("hahha");break;case 55:hello_main();break;case 56:printf("Goodbye!");exit(0);}}}struct /*图书结构体*/ {int number;char name[20];char press[20];char writer[20];int price;}books[200];struct /*学生结构体*/ {int number;char name[20];char sex[6];int grade;}students[200];adm_information() /*管理员菜单*/ {for(; ;){switch(administrator_menu_select()){case 49:books_information_input();break;case 51:printf("Guest\n");break;case 52:students_information_input();break;case 53:printf("Guest of gentleman\n");break;case 54:printf("hahha");break;case 55:hello_main();break;case 56:printf("Goodbye!");exit(0);}}}int books_information_input() /*图书信息输入函数*/ {int m,i,s;char h;printf("input the number of the books you want to operate:");scanf("%d",&m);for(i=1;i<m+1;i++){printf("please input the %dth book's number:",i);scanf("%d",&books[i].number);printf("\n please input the %dth book's name:",i);scanf("%s",books[i].name);printf("\n please input the %dth book's press:",i);scanf("%s",books[i].press);printf("\n please input the %dth book's writer:",i);scanf("%s",books[i].writer);printf("\n please input the %dth book's price:",i);scanf("%d",&books[i].price);printf("\n\n");}printf("\ninformation of the students has been inputed\n");printf("1 to return higher menu\n"); /*返回上一级菜单,即管理员选择功能菜单*/h=getche();if(h==1)hello_adm_menu();}students_information_input() /*学生信息输入函数*/ {int m,i,s;printf("input the number of the students you want to operate:");scanf("%d",&m);for(i=1;i<m+1;i++){printf("\nplease input the %dth student's number:",i);scanf("%d",&students[i].number);printf("\n please input the %dth student's name:",i);scanf("%s",students[i].name);printf("\n please input the %dth student's sex:",i);scanf("%s",students[i].sex);printf("\n please input the %dth student's grade:",i);scanf("%d",&students[i].grade);}printf("\ninformation of the books has been inputed\n\n"); }main(){for(; ;){switch(main_menu_select()){case 49:adm_information();break;case 50:printf("helloo");break;case 51:printf("hellooo");break;case 52:printf("helloooo");break;case 53:printf("hellooooo");break;case 54:printf("Goodbye!");exit(0);}}}。

相关文档
最新文档