C语言实现宿舍管理系统课程设计
#include"stdio.h"
#include"stdlib.h"
#include"string.h"
#include "conio.h"
#include "windows.h"
#define MAX 1000
/*结构体类型*/
typedef struct
{
int num;/*学号*/
char name[20];/*姓名*/
char sex[5];/*性别*/
int age;/*年龄*/
char studentclass[20];/*班级*/
int dorm;/*宿舍号*/
}STUDENTS;
//查找指针
typedef struct Points
{
int a;
struct Points *points;
}Points;
char xiugai[10]="修改";
char chaxun[10]="查询";
char xuehao[]="学号";
char xingming[]="姓名";
char xingbie[]="性别";
char nianling[]="年龄";
char banji[]="班级";
char sushe[]="宿舍";
/*共用的功能块 */
void pause(){
int i;
printf("
按任意键加回车返回主菜单!");
scanf("%d",&i);
getchar();
}
void print(STUDENTS stu[],int point){
printf("
学号:%d,姓名:%s,性别:%s,年龄:%d,班级:%s,宿舍号: %d
",
stu[point].num,stu[point].name,stu[point].sex,stu[point].age,stu[point].studentclass,stu[point].dorm);
}
void printfNotFound(){
printf("找不到该数据
");
}
void printSearch(STUDENTS stu[],int i){
printf(" %7d%11s%10s%10d%12s%12d
",stu[i].num,stu[i].name,stu[i].sex,stu[i].age,stu[i].studentclass,stu[i].dorm);
}
void printHead(){
printf(" -------------------------------------------------------------------------------
");
printf(" -------------------------------------------------------------------------------
");
printf(" 学号: 姓名: 性别: 年龄: 班级: 宿舍号:
");
printf(" -------------------------------------------------------------------------------
");
printf(" -------------------------------------------------------------------------------
");
}
//默认继续
int a=1;
void selectOperate(){
button:
printf("继续操作请按1,返回主菜单请按0 ");
scanf("%d",&a);
if(!(a==1||a==0))
{
printf("请输入正确的指令");
goto button;
}
}
//读取文件,返回的是总个数
int read_file(STUDENTS stu[])
{
FILE *fp;
int point=-1;
fp=fopen("stu.txt","rt");
if(fp==NULL)
{
printf("
*****库存文件不存在!请创建");
return 0;
}
while(!feof(fp))
{
point++;
fread(&stu[point],sizeof(STUDENTS),1,fp);
}
fclose(fp);
return point;
}
//存储数据到文件中
void save_file(STUDENTS stu[],int sum)//sum是总个数
{
FILE *fp;
int i;
if((fp=fopen("temp.txt","w"))==NULL)
{
printf("写文件错误!
");
return;
}
for(i=0;i if(fwrite(&stu[i],sizeof(STUDENTS),1,fp)!=1) printf("写文件错误! "); fclose(fp); remove("stu.txt"); rename("temp.txt","stu.txt"); } /*创建学生信息*/ //返回的是总数 int input(STUDENTS stu[],int sum) { int x; for(;sum { system("cls"); printf(" ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ "); printf(" ▄ ▄ "); printf(" ▄ 创建学生宿舍信息 ▄ "); printf(" ▄ ▄ "); printf(" ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ "); printf(" 录入学生信息 (最多%d个) ",MAX); printf(" ---------------------------- "); printf(" 第%d个学生 ",sum+1); printf(" 请输入学生的学号:"); scanf("%d",&stu[sum].num); printf(" 请输入学生的姓名:"); scanf("%s",stu[sum].name); printf(" 请输入学生的性别:"); scanf("%s",stu[sum].sex); printf(" 请输入学生的年龄:"); scanf("%d",&stu[sum].age); printf(" 请输入学生的班级:"); scanf("%s",stu[sum].studentclass); printf(" 请输入学生的宿舍号:"); scanf("%d",&stu[sum].dorm); printf(" 创建成功!"); //选择操作 selectOperate(); if(a==0) return sum+1; } return sum+1; } /*打印学生信息*/ void output(STUDENTS stu[],int sum) { int i; system("cls"); printf(" ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ "); printf(" ▄ ▄ "); printf(" ▄ 打印学生宿舍信息 ▄ "); printf(" ▄ ▄ "); printf(" ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ "); printHead(); for(i=0;i printSearch(stu,i); pause(); } /*排序 */ /*复制student*/ //将排好的装在一个新的students数组里 ,不要存到文件中 void cpStu(STUDENTS stu0[],STUDENTS stu[],int sum) { int i; for(i=0;i stu[i].num=stu0[i].num; strcpy(stu[i].name,stu0[i].name); strcpy(stu[i].sex,stu0[i].sex); stu[i].age=stu0[i].age; strcpy(stu[i].studentclass,stu0[i].studentclass); stu[i].dorm=stu0[i].dorm; } } /*对数据元组排序*/ void exchangeData(STUDENTS *stu1,STUDENTS *stu2){ stu1->num=stu2->num; stu1->dorm=stu2->dorm; stu1->age=stu2->age; strcpy(stu1->name,stu2->name); strcpy(stu1->sex,stu2->sex); strcpy(stu1->studentclass,stu2->studentclass); } int selectSort(){ int choice; printf(" ********请您选择条件进行排序******** "); printf(" 1. 学号 "); printf(" 2. 班级 "); printf(" 3. 宿舍号 "); printf(" 4. 姓名 "); printf(" 0. 返回主菜单 "); printf(" 请选择(0-3):"); scanf("%d",&choice); return choice; } /*根据宿舍号从小到大排序 冒泡*/ void sortByDorm(STUDENTS stu0[],int sum,STUDENTS stup[]) { STUDENTS stu1; //中间变量 int i,j; cpStu(stu0,stup,sum); for(i=0;i for(j=0;j if(stup[j].dorm>stup[j+1].dorm) { exchangeData(&stu1,&stup[j]); exchangeData(&stup[j],&stup[j+1]); exchangeData(&stup[j+1],&stu1); } } /*根据班级从小到大排序 选择*/ void sortByClass(STUDENTS stu0[],int sum,STUDENTS stup[]) { STUDENTS stu1; //中间变量 int i,j,k; cpStu(stu0,stup,sum); for(i=0;i { k=i; for(j=i+1;j if(strcmp(stup[k].studentclass,stup[j].studentclass)>0) k=j; if(k!=i) { exchangeData(&stu1,&stup[i]); exchangeData(&stup[i],&stup[k]); exchangeData(&stup[k],&stu1); } } } /*根据姓名从大到小排序 折半插入排序*/ //因为这里是从stu[1]开始操作的,所以得再创个中间变量 void sortByName(STUDENTS stu0[],int sum,STUDENTS stup[]) { STUDENTS stu1; //中间变量 STUDENTS stu[1000]; int i,j,low,high,mid; for(i=0;i stu[i+1].num=stu0[i].num; strcpy(stu[i+1].name,stu0[i].name); strcpy(stu[i+1].sex,stu0[i].sex); stu[i+1].age=stu0[i].age; strcpy(stu[i+1].studentclass,stu0[i].studentclass); stu[i+1].dorm=stu0[i].dorm; } for(i=2;i exchangeData(&stu1,&stu[i]); /*保存待插入元素到stu1*/ low=1;high=i-1; while(low<=high) { mid=(low+high)/2; if(strcmp(stu1.name,stu[mid].name)>0) low=mid+1; else high=mid-1; } for(j=i-1;j>=high+1;j--) exchangeData(&stu[j+1],&stu[j]);//后移元素,留出插入空位 exchangeData(&stu[high+1],&stu1); } for(i=0;i stup[i].num=stu[i+1].num; strcpy(stup[i].name,stu[i+1].name); strcpy(stup[i].sex,stu[i+1].sex); stup[i].age=stu[i+1].age; strcpy(stup[i].studentclass,stu[i+1].studentclass); stup[i].dorm=stu[i+1].dorm; } } /*根据学号从大到小排序 插入的希尔排序*/ void ShellInsert(STUDENTS stup[],int sum,int dk){ int i,j,k; STUDENTS stu1;//中间变量 for(k=0;k for(i=dk+k;i if(stup[i].num { exchangeData(&stu1,&stup[i]); for(j=i-dk;j>=0&&stu1.num exchangeData(&stup[j+dk],&stup[j]); exchangeData(&stup[j+dk],&stu1); } } void sortByNum(STUDENTS stu[],int sum,STUDENTS stup[]) { int i,x; cpStu(stu,stup,sum); int dlta[5]={5,4,3,2,1}; for(x=0;x<5;x++) ShellInsert(stup,sum,dlta[x]); } //总的函数 void sortStudent(STUDENTS stu[],int sum){ STUDENTS stup[1000];//引用,把排好序的放在这里,不跟原来的混淆 int choice,x,i; do{ system("cls"); printf(" ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ "); printf(" ▄ ▄ "); printf(" ▄ 学生宿舍信息排序 ▄ "); printf(" ▄ ▄ "); printf(" ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ "); select: choice=selectSort(); system("cls"); printf(" ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ "); printf(" ▄ ▄ "); printf(" ▄ 学生宿舍信息排序 ▄ "); printf(" ▄ ▄ "); printf(" ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ "); switch(choice) { case 1: sortByNum(stu,sum,stup); break;/*学生学号信息顺序*/ case 2: sortByClass(stu,sum,stup);break;/*学生班级信息顺序*/ case 3: sortByDorm(stu,sum,stup); break;/*学生宿舍信息顺序*/ case 4: sortByName(stu,sum,stup); break;/*学生姓名信息顺序*/ case 0: break; } //打印排好序的 printHead(); for(i=0;i printSearch(stup,i); if(choice==1||choice==2||choice==3||choice==4) { printf(" "); button: printf("继续查询请按1,返回主菜单请按0 "); scanf("%d",&x); if(x==1) x=1; else if(x==0) continue; else { printf("请输入正确的指令 "); goto button; } } else if(choice==0) x=0; else { printf(" 请输入正确的指令 "); goto select; } }while(x==1); } /* 根据条件查找指针point*/ /// //查询或者修改的选择; int selectChoice(char tiaojian[20]){ int choice; printf(" ********您想根据哪个条件%s******** ",tiaojian); printf(" 1. 学号 "); printf(" 2. 姓名 "); printf(" 3. 性别 "); printf(" 4. 年龄 "); printf(" 5. 班级 "); printf(" 6. 宿舍号 "); printf(" 0. 返回主菜单 "); printf(" 请选择(0-6):"); scanf("%d",&choice); return choice; } ///????????????????????????????为什么这里的指针得返回菜可行,参数不是指针,操作的是地址的???? Points *connectPoint(Points *r,Points *p,int i){ p=(Points *)malloc(sizeof(Points)); p->a=i; r->points=p; r=p; return r; } //choice是指主菜单中的功能选项,字符数组tiaojian为相应的字符,比如如果选择查询的话, //tiaojian传参进来的应该为 "查询",这里是为了提高函数的复用性。 Points *findPoint(STUDENTS stu[],int sum,int choice,char tiaojian[]) { int i,j=0; Points *p,*q,*r; q=(Points *)malloc(sizeof(Points));r=q; int num,age,dorm;char classs[20],sex[5],name[20]; printf(" 请输入您要查找的学生的%s",tiaojian); switch(choice) { case 1: scanf("%d",&num); for(i=0;i if(num==stu[i].num) r=connectPoint(r,p,i); break; case 2: scanf("%s",name);for(i=0;i case 3: scanf("%s",sex);for(i=0;i case 4: scanf("%d",&age);for(i=0;i case 5: scanf("%s",classs);for(i=0;i case 6: scanf("%d",&dorm);for(i=0;i } r->points=NULL; return q; } // /*查询学生信息*/ void inquire(STUDENTS stu[],int sum) { int choice; Points *p; do{ system("cls"); printf(" ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ "); printf(" ▄ ▄ "); printf(" ▄ 查询学生宿舍信息 ▄ "); printf(" ▄ ▄ "); printf(" ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ "); button: choice=selectChoice(chaxun); system("cls"); printf(" ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ "); printf(" ▄ ▄ "); printf(" ▄ 查询学生宿舍信息 ▄ "); printf(" ▄ ▄ "); printf(" ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ "); switch里面不能调用排序功能,为什么????????? switch(choice) { case 1:p=findPoint(stu,sum,choice,xuehao);break; case 2:p=findPoint(stu,sum,choice,xingming);break; case 3:p=findPoint(stu,sum,choice,xingbie);break; case 4:p=findPoint(stu,sum,choice,nianling);break; case 5:p=findPoint(stu,sum,choice,banji);break; case 6:p=findPoint(stu,sum,choice,sushe);break; case 0:return; default :printf("请输入正确的指令");goto button;//不断循环; } if(p->points!=NULL) { p=p->points; printHead(); while(p!=NULL) { printSearch(stu,p->a); p=p->points; } } else printfNotFound(); //选择操作 selectOperate(); }while(a); } //二分法只适用于查找一个 目前只有学号,姓名,宿舍排序 Points *findPoint2(STUDENTS stu[],int sum,int choice,char tiaojian[]) { int i,j=0; Points *p,*q,*r; q=(Points *)malloc(sizeof(Points));r=q; int num,age,dorm;char classs[20],sex[5],name[20]; printf(" 请输入您要查找的学生的%s",tiaojian); switch(choice) { case 1: scanf("%d",&num);break; case 2: scanf("%s",name);break; case 3: scanf("%d",&dorm);break; } int flag=0; int low=0,high=sum-1,mid; while(low<=high){ mid=(low+high)/2; switch(choice) { case 1:if(num==stu[mid].num){r=connectPoint(r,p,mid);printf("mid==%d",mid);flag=1;} else if(stu[mid].num>num)high=mid-1;else low=mid+1; break; case 2: if(strcmp(name,stu[mid].name)==0){r=connectPoint(r,p,mid);flag=1;} if(strcmp(stu[mid].name,name)>0)high=mid-1;else low=mid+1;break; case 3: if(dorm==stu[mid].dorm){r=connectPoint(r,p,mid);flag=1;} if(stu[mid].dorm>dorm)high=mid-1;else low=mid+1;break; } //如果找到,就跳出循环 if(flag) break; } r->points=NULL; return q; } /*二分法查询学生信息*/ void inquire2(STUDENTS stu[],int sum) { STUDENTS stup1[1000];//引用,把排好序的放在这里,不跟原来的混淆 STUDENTS stup2[1000];//引用,把排好序的放在这里,不跟原来的混淆 STUDENTS stup3[1000];//引用,把排好序的放在这里,不跟原来的混淆 //二分法得先排序 sortByNum(stu,sum,stup1); sortByName(stu,sum,stup2); sortByDorm(stu,sum,stup3); int choice; Points *p; do{ system("cls"); printf(" ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ "); printf(" ▄ ▄ "); printf(" ▄ 查询学生宿舍信息 ▄ "); printf(" ▄ ▄ "); printf(" ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ "); button: printf(" ********您想根据哪个条件查询******** "); printf(" 1. 学号 "); printf(" 2. 姓名 "); printf(" 3. 宿舍号 "); printf(" 0. 返回主菜单 "); printf(" 请选择(0-3):"); scanf("%d",&choice); system("cls"); printf(" ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ "); printf(" ▄ ▄ "); printf(" ▄ 查询学生宿舍信息 ▄ "); printf(" ▄ ▄ "); printf(" ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ "); switch里面不能调用排序功能,为什么????????? switch(choice) { case 1:p=findPoint2(stup1,sum,choice,xuehao);break;//二分法查询 case 2:p=findPoint2(stup2,sum,choice,xingming);break;//二分法查询 case 3:p=findPoint2(stup3,sum,choice,sushe);break;//二分法查询 case 0:return; default :printf("请输入正确的指令");goto button;//不断循环; } if(p->points!=NULL) { p=p->points; printHead(); while(p!=NULL) { if(choice==1) { printSearch(stup1,p->a); p=p->points;} if(choice==2) { printSearch(stup2,p->a); p=p->points;} if(choice==3) { printSearch(stup3,p->a); p=p->points;} } } else printfNotFound(); //选择操作 selectOperate(); }while(a); } //修改和删除判断输入学生个数 int operateNum(int sum){ int n; printf("请输入你要操作的学生的个数:"); scanf("%d",&n); if(n>sum) { printf(" 输入学生个数超过总量,操作失败 "); selectOperate(); return 0; } else if(n<=0) { printf(" 输入学生个数不能小于或等于0,操作失败 "); selectOperate(); return 0; } return n; } /*只能根据学号删除学生信息*/ void exchangeData(STUDENTS *stu1,STUDENTS *stu2); //返回总数 int deletel(STUDENTS stu[],int sum) { a=1; system("cls"); int i,j=0,n=0,flag=1; Points *p; printf(" ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ "); printf(" ▄ ▄ "); printf(" ▄ 删除学生宿舍信息 ▄ "); printf(" ▄ ▄ "); printf(" ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ "); while(n==0)//这里接收到的两个数,n判断学生个数,a判断是否返回主菜单 { n=operateNum(sum); //选择操作 if(a==0) return sum; //0就返回主菜单 } do{ if(flag){ system("cls"); Points *p; printf(" ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ "); printf(" ▄ ▄ "); printf(" ▄ 删除学生宿舍信息 ▄ "); printf(" ▄ ▄ "); printf(" ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ "); } //查一个删一个 p=findPoint(stu,sum,1,xuehao); p=p->points; if(p!=NULL) { i=p->a; //把后面的一次覆盖掉前面一个 for(;i exchangeData(&stu[i],&stu[i+1]); printf("删除成功 "); flag=0; j++; if(j==n) { printf(" 删除操作已完成 "); //选择操作 selectOperate(); if(a==0) return sum-n; else deletel(stu,sum-n); } } else{ printf("输入的学号不存在,操作失败 "); //选择操作 selectOperate(); if(a==0) return sum-j; } }while(a==1&&j } /*只能根据学号修改学生信息*/ void change(STUDENTS stu[],int sum) { int choice; Points *p; do{ system("cls"); printf(" ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ "); printf(" ▄ ▄ "); printf(" ▄ 修改学生宿舍信息 ▄ "); printf(" ▄ ▄ "); printf(" ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ "); p=findPoint(stu,sum,1,xuehao); p=p->points; if(p!=NULL) { system("cls"); printf(" ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ "); printf(" ▄ ▄ "); printf(" ▄ 修改学生宿舍信息 ▄ "); printf(" ▄ ▄ "); printf(" ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ "); int i=p->a; print(stu,i); button: choice=selectChoice(xiugai); switch(choice) { case 1:printf(" 请输入你改的新学号");scanf("%d",&stu[i].num); break; case 2:printf(" 请输入你改的新姓名");scanf("%s",stu[i].name); break; case 3:printf(" 请输入你改的新性别");scanf("%s",stu[i].sex); break; case 4:printf(" 请输入你改的新年龄");scanf("%d",&stu[i].age); break; case 5:printf(" 请输入你改的新班级");scanf("%s",stu[i].studentclass); break; case 6:printf(" 请输入你改的新宿舍");scanf("%d",&stu[i].dorm); break; case 0:return; default :printf("请输入正确的指令");goto button; } printf(" 修改成功:"); print(stu,i); } else printfNotFound(); //选择操作 selectOperate(); if(a==0) return; }while(a); } void pagedis() { printf(" ********************************** "); printf(" * * "); printf(" * * "); printf(" * * "); printf(" * 欢迎进入学生宿舍信息管理系统 * "); printf(" * * "); printf(" * * "); printf(" * * "); printf(" ********************************** "); } //欢迎 void welcome(){ char heart[30][150]={ " ************ ************", " ****************** ******************", " ******************#******* **************************", " **********************#********* ********************************", " **********************##########*** **************#******************** ", " **********************#*********#**** **##********#************************ ", " *********##########**#****#****#**********##****#************************** ", " **********#*******#*#*****#***#***************#********#########*********** ", " **********#*****#********#***********#####***#********#*******#********** ", " ***********#***#********#***************#***#******#*#****#**#********* ", " ***********##**********#**************#*****#****#***#*****#*#******* ", " **********##*********#*#************#*****####*****#*******#******* ", " ********#**#*******#***#************#*************#************** ", " *****#****#*****#*****#************#************#************ ", " **#**********#*******#******######************#********** ", " **********#*********#*****########################### ", " ************************************************** ", " ********************************************** ", " ****************************************** ", " ************************************** ", " ********************************** ", " ****************************** ", " ************************** ", " ********************** ", " ****************** ", " ************** ", " ********** ", " ****** ", " ** " }; int i; for(i=0;i<29;i++) //逐行打印 printf("%s ",heart[i]); } void bye(){ system("cls"); char heart[11][150]={ " _____ _ _ ", " |_ _| | |_ __ _ _ _ | |__ ___ o O O ", " | | | ' / _` | | ' | / / (_-< o ", " _|_|_ |_||_| __,_| |_||_| |__ /__/_ TS__[O] ", " _|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""| {======| ", " "`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'http://www.jb51.net/article/o--000' " }; int i; printf(" "); for(i=0;i<6;i++) //逐行打印 printf("%s ",heart[i]); } void designer(){ printf(" ☆☆☆☆☆☆☆☆★★设计者信息★★☆☆☆☆☆☆☆☆ "); printf(" ●● ●● "); printf(" ●● 姓名: ●● "); printf(" ●● ●● "); printf(" ●● 班级: ●● "); printf(" ●● ●● "); printf(" ●● 学号: ●● "); printf(" ●● ●● "); printf(" ☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆ "); } void check() { char userName[5];/*用户名*/ char userPWD[5];/*密码*/ int i; system("color 3C"); for(i = 1; i < 4; i++) { /*用户名和密码均为123;*/ printf(" 请输入您的用户名(123):"); gets(userName); printf(" 请输入您的密码(123):"); gets(userPWD); if ((strcmp(userName,"123")==0) && (strcmp(userPWD,"123")==0))/*验证用户名和密码*/ { system("cls"); welcome(); printf(" 3秒后自动跳转"); Sleep(3000); return; } else { if (i < 3) printf("用户名或密码错误,请重新输入!"); else { printf("您已连续3次将用户名或密码输错,系统将退出!"); exit(1); } } } } void menu() { STUDENTS stu[20]; int choice,sum; sum=read_file(stu); if(sum==0) { printf("首先录入基本库存信息!按回车后进入***** "); getch(); sum=input(stu,sum); } system("cls"); do { system("cls"); button: printf(" ********学生宿舍信息管理系统******** "); printf(" 1. 创建学生宿舍信息 "); printf(" 2. 打印学生宿舍信息 "); printf(" 3. 查询学生宿舍信息 "); printf(" 4. 修改学生宿舍信息 "); printf(" 5. 删除学生宿舍信息 "); printf(" 6. 学生宿舍信息排序 "); printf(" 0. 退出系统 "); printf(" 请选择(0-6):"); scanf("%d",&choice); switch(choice) { case 1: sum=input(stu,sum); break;/*创建学生信息*/ case 2: output(stu,sum) ; break;/*打印学生信息*/ case 3: inquire(stu,sum); break;/*查询学生信息*/ case 4: change(stu,sum); break;/*修改学生信息*/ case 5: sum=deletel(stu,sum);break;/*删除学生信息*/ case 6: sortStudent(stu,sum); break;/*学生信息顺序*/ case 0: bye();designer();break; default:system("cls"); printf(" 请输入正确的指令! "); goto button; } }while(choice!=0); save_file(stu,sum); } int main() { pagedis(); check(); menu(); return 0; }