C语言实现宿舍管理系统课程设计
宿舍管理系统C语言源码,供大家参考,具体内容如下
内容摘要
学生宿舍管理系统时应对学生宿舍管理的现代化、网络化,逐步摆脱学生宿舍管理的人工管理方式,提高学生宿舍管理效率而开发的,它包括了对学生宿舍基本信息管理,其功能包括对这些基本信息的增、删、改、查等基本功能,并将这些功能与文件读写相结合形成文档使管理者一目了然,也适合长时间的保存,数据不容易丢失;其中在输出时穿插着冒泡排序、希尔排序、折半拆入排序、二分查找等算法,按顺序输出学生信息等。综上,这无疑为信息的管理存储提供了一个方便、快捷的操作方式。
关键词
二分查找、排序算法及分析、文件操作
系统概览
开发工具
Visual C++ 6.0
函数功能
源码
#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("\n\n按任意键加回车返回主菜单!"); scanf("%d",&i); getchar(); } void print(STUDENTS stu[],int point){ printf("\n\n\n学号:%d,姓名:%s,性别:%s,年龄:%d,班级:%s,宿舍号: %d\n", stu[point].num,stu[point].name,stu[point].sex,stu[point].age,stu[point].studentclass,stu[point].dorm); } void printfNotFound(){ printf("找不到该数据\n"); } void printSearch(STUDENTS stu[],int i){ printf(" %7d%11s%10s%10d%12s%12d\n\n",stu[i].num,stu[i].name,stu[i].sex,stu[i].age,stu[i].studentclass,stu[i].dorm); } void printHead(){ printf(" -------------------------------------------------------------------------------\n"); printf(" -------------------------------------------------------------------------------\n"); printf(" 学号: 姓名: 性别: 年龄: 班级: 宿舍号: \n"); printf(" -------------------------------------------------------------------------------\n"); printf(" -------------------------------------------------------------------------------\n\n\n"); } //默认继续 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("\n\n*****库存文件不存在!请创建"); 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("写文件错误!\n"); return; } for(i=0;i<sum;i++) if(fwrite(&stu[i],sizeof(STUDENTS),1,fp)!=1) printf("写文件错误!\n"); fclose(fp); remove("stu.txt"); rename("temp.txt","stu.txt"); } /*创建学生信息*/ //返回的是总数 int input(STUDENTS stu[],int sum) { int x; for(;sum<MAX;sum++) { system("cls"); printf(" ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇\n"); printf(" ▄ ▄\n"); printf(" ▄ 创建学生宿舍信息 ▄\n"); printf(" ▄ ▄\n"); printf(" ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇\n"); printf("\n\n 录入学生信息 (最多%d个)\n",MAX); printf(" ----------------------------\n"); printf("\n 第%d个学生\n",sum+1); printf("\n 请输入学生的学号:"); scanf("%d",&stu[sum].num); printf("\n 请输入学生的姓名:"); scanf("%s",stu[sum].name); printf("\n 请输入学生的性别:"); scanf("%s",stu[sum].sex); printf("\n 请输入学生的年龄:"); scanf("%d",&stu[sum].age); printf("\n 请输入学生的班级:"); scanf("%s",stu[sum].studentclass); printf("\n 请输入学生的宿舍号:"); 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(" ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇\n"); printf(" ▄ ▄\n"); printf(" ▄ 打印学生宿舍信息 ▄\n"); printf(" ▄ ▄\n"); printf(" ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇\n"); printHead(); for(i=0;i<sum;i++) printSearch(stu,i); pause(); } /*排序 */ /*复制student*/ //将排好的装在一个新的students数组里 ,不要存到文件中 void cpStu(STUDENTS stu0[],STUDENTS stu[],int sum) { int i; for(i=0;i<sum;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("\n\n\n ********请您选择条件进行排序********\n\n"); printf(" 1. 学号\n\n"); printf(" 2. 班级\n\n"); printf(" 3. 宿舍号\n\n"); printf(" 4. 姓名\n\n"); printf(" 0. 返回主菜单\n\n"); 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<sum-1;i++) for(j=0;j<sum-1-i;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<sum-1;i++) { k=i; for(j=i+1;j<sum;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<sum;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<sum+1;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<sum;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<dk;k++) for(i=dk+k;i<sum;i=i+dk) if(stup[i].num<stup[i-dk].num) { exchangeData(&stu1,&stup[i]); for(j=i-dk;j>=0&&stu1.num<stup[j].num;j=j-dk)//记录向后移 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(" ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇\n"); printf(" ▄ ▄\n"); printf(" ▄ 学生宿舍信息排序 ▄\n"); printf(" ▄ ▄\n"); printf(" ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇\n"); select: choice=selectSort(); system("cls"); printf(" ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇\n"); printf(" ▄ ▄\n"); printf(" ▄ 学生宿舍信息排序 ▄\n"); printf(" ▄ ▄\n"); printf(" ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇\n"); 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<sum;i++) printSearch(stup,i); if(choice==1||choice==2||choice==3||choice==4) { printf("\n\n"); button: printf("继续查询请按1,返回主菜单请按0 "); scanf("%d",&x); if(x==1) x=1; else if(x==0) continue; else { printf("请输入正确的指令\n"); goto button; } } else if(choice==0) x=0; else { printf("\n\t\t请输入正确的指令\n"); goto select; } }while(x==1); } /* 根据条件查找指针point*/ /// //查询或者修改的选择; int selectChoice(char tiaojian[20]){ int choice; printf("\n\n\n ********您想根据哪个条件%s********\n\n",tiaojian); printf(" 1. 学号\n\n"); printf(" 2. 姓名\n\n"); printf(" 3. 性别\n\n"); printf(" 4. 年龄\n\n"); printf(" 5. 班级\n\n"); printf(" 6. 宿舍号\n\n"); printf(" 0. 返回主菜单\n\n"); 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(" \n\n请输入您要查找的学生的%s",tiaojian); switch(choice) { case 1: scanf("%d",&num); for(i=0;i<sum;i++) if(num==stu[i].num) r=connectPoint(r,p,i); break; case 2: scanf("%s",name);for(i=0;i<sum;i++)if(strcmp(name,stu[i].name)==0)r=connectPoint(r,p,i);break; case 3: scanf("%s",sex);for(i=0;i<sum;i++)if(strcmp(sex,stu[i].sex)==0)r=connectPoint(r,p,i);break; case 4: scanf("%d",&age);for(i=0;i<sum;i++)if(age==stu[i].age)r=connectPoint(r,p,i);break; case 5: scanf("%s",classs);for(i=0;i<sum;i++)if(strcmp(classs,stu[i].studentclass)==0)r=connectPoint(r,p,i);break; case 6: scanf("%d",&dorm);for(i=0;i<sum;i++)if(dorm==stu[i].dorm)r=connectPoint(r,p,i);break; } r->points=NULL; return q; } // /*查询学生信息*/ void inquire(STUDENTS stu[],int sum) { int choice; Points *p; do{ system("cls"); printf(" ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇\n"); printf(" ▄ ▄\n"); printf(" ▄ 查询学生宿舍信息 ▄\n"); printf(" ▄ ▄\n"); printf(" ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇\n"); button: choice=selectChoice(chaxun); system("cls"); printf(" ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇\n"); printf(" ▄ ▄\n"); printf(" ▄ 查询学生宿舍信息 ▄\n"); printf(" ▄ ▄\n"); printf(" ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇\n"); 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(" \n\n请输入您要查找的学生的%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(" ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇\n"); printf(" ▄ ▄\n"); printf(" ▄ 查询学生宿舍信息 ▄\n"); printf(" ▄ ▄\n"); printf(" ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇\n"); button: printf("\n\n\n ********您想根据哪个条件查询********\n\n"); printf(" 1. 学号\n\n"); printf(" 2. 姓名\n\n"); printf(" 3. 宿舍号\n\n"); printf(" 0. 返回主菜单\n\n"); printf(" 请选择(0-3):"); scanf("%d",&choice); system("cls"); printf(" ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇\n"); printf(" ▄ ▄\n"); printf(" ▄ 查询学生宿舍信息 ▄\n"); printf(" ▄ ▄\n"); printf(" ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇\n"); 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("\n\n 输入学生个数超过总量,操作失败\n"); selectOperate(); return 0; } else if(n<=0) { printf("\n\n 输入学生个数不能小于或等于0,操作失败\n"); 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(" ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇\n"); printf(" ▄ ▄\n"); printf(" ▄ 删除学生宿舍信息 ▄\n"); printf(" ▄ ▄\n"); printf(" ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇\n"); while(n==0)//这里接收到的两个数,n判断学生个数,a判断是否返回主菜单 { n=operateNum(sum); //选择操作 if(a==0) return sum; //0就返回主菜单 } do{ if(flag){ system("cls"); Points *p; printf(" ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇\n"); printf(" ▄ ▄\n"); printf(" ▄ 删除学生宿舍信息 ▄\n"); printf(" ▄ ▄\n"); printf(" ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇\n"); } //查一个删一个 p=findPoint(stu,sum,1,xuehao); p=p->points; if(p!=NULL) { i=p->a; //把后面的一次覆盖掉前面一个 for(;i<sum-1;i++) exchangeData(&stu[i],&stu[i+1]); printf("删除成功\n"); flag=0; j++; if(j==n) { printf("\n\n删除操作已完成\n"); //选择操作 selectOperate(); if(a==0) return sum-n; else deletel(stu,sum-n); } } else{ printf("输入的学号不存在,操作失败\n"); //选择操作 selectOperate(); if(a==0) return sum-j; } }while(a==1&&j<n); } /*只能根据学号修改学生信息*/ void change(STUDENTS stu[],int sum) { int choice; Points *p; do{ system("cls"); printf(" ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇\n"); printf(" ▄ ▄\n"); printf(" ▄ 修改学生宿舍信息 ▄\n"); printf(" ▄ ▄\n"); printf(" ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇\n"); p=findPoint(stu,sum,1,xuehao); p=p->points; if(p!=NULL) { system("cls"); printf(" ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇\n"); printf(" ▄ ▄\n"); printf(" ▄ 修改学生宿舍信息 ▄\n"); printf(" ▄ ▄\n"); printf(" ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇\n"); int i=p->a; print(stu,i); button: choice=selectChoice(xiugai); switch(choice) { case 1:printf("\n 请输入你改的新学号");scanf("%d",&stu[i].num); break; case 2:printf("\n 请输入你改的新姓名");scanf("%s",stu[i].name); break; case 3:printf("\n 请输入你改的新性别");scanf("%s",stu[i].sex); break; case 4:printf("\n 请输入你改的新年龄");scanf("%d",&stu[i].age); break; case 5:printf("\n 请输入你改的新班级");scanf("%s",stu[i].studentclass); break; case 6:printf("\n 请输入你改的新宿舍");scanf("%d",&stu[i].dorm); break; case 0:return; default :printf("请输入正确的指令");goto button; } printf("\n 修改成功:"); print(stu,i); } else printfNotFound(); //选择操作 selectOperate(); if(a==0) return; }while(a); } void pagedis() { printf(" \n\n\n **********************************\n"); printf(" * *\n"); printf(" * *\n"); printf(" * *\n"); printf(" * 欢迎进入学生宿舍信息管理系统 *\n"); printf(" * *\n"); printf(" * *\n"); printf(" * *\n"); printf(" **********************************\n"); } //欢迎 void welcome(){ char heart[30][150]={ " ************ ************", " ****************** ******************", " ******************#******* **************************", " **********************#********* ********************************", " **********************##########*** **************#******************** ", " **********************#*********#**** **##********#************************ ", " *********##########**#****#****#**********##****#************************** ", " **********#*******#*#*****#***#***************#********#########*********** ", " **********#*****#********#***********#####***#********#*******#********** ", " ***********#***#********#***************#***#******#*#****#**#********* ", " ***********##**********#**************#*****#****#***#*****#*#******* ", " **********##*********#*#************#*****####*****#*******#******* ", " ********#**#*******#***#************#*************#************** ", " *****#****#*****#*****#************#************#************ ", " **#**********#*******#******######************#********** ", " **********#*********#*****########################### ", " ************************************************** ", " ********************************************** ", " ****************************************** ", " ************************************** ", " ********************************** ", " ****************************** ", " ************************** ", " ********************** ", " ****************** ", " ************** ", " ********** ", " ****** ", " ** " }; int i; for(i=0;i<29;i++) //逐行打印 printf("%s\n",heart[i]); } void bye(){ system("cls"); char heart[11][150]={ "\t\t _____ _ _ ", "\t\t |_ _| | |_ __ _ _ _ | |__ ___ o O O ", "\t\t | | | ' \\ / _` | | ' \\ | / / (_-< o ", "\t\t _|_|_ |_||_| \\__,_| |_||_| |_\\_\\ /__/_ TS__[O] ", "\t\t_|\"\"\"\"\"|_|\"\"\"\"\"|_|\"\"\"\"\"|_|\"\"\"\"\"|_|\"\"\"\"\"|_|\"\"\"\"\"| {======| ", "\t\t\"`-0-0-\'\"`-0-0-\'\"`-0-0-\'\"`-0-0-\'\"`-0-0-\'\"`-0-0-\'./o--000' " }; int i; printf("\n\n"); for(i=0;i<6;i++) //逐行打印 printf("%s\n",heart[i]); } void designer(){ printf("\n\n\t\t☆☆☆☆☆☆☆☆★★设计者信息★★☆☆☆☆☆☆☆☆\n\n"); printf("\t\t ●● ●●\n\n"); printf("\t\t ●● 姓名: ●●\n\n"); printf("\t\t ●● ●●\n\n"); printf("\t\t ●● 班级: ●●\n\n"); printf("\t\t ●● ●●\n\n"); printf("\t\t ●● 学号: ●●\n\n"); printf("\t\t ●● ●●\n\n"); printf("\t\t☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆\n"); } void check() { char userName[5];/*用户名*/ char userPWD[5];/*密码*/ int i; system("color 3C"); for(i = 1; i < 4; i++) { /*用户名和密码均为123;*/ printf("\n 请输入您的用户名(123):"); gets(userName); printf("\n 请输入您的密码(123):"); gets(userPWD); if ((strcmp(userName,"123")==0) && (strcmp(userPWD,"123")==0))/*验证用户名和密码*/ { system("cls"); welcome(); printf("\n 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("首先录入基本库存信息!按回车后进入*****\n"); getch(); sum=input(stu,sum); } system("cls"); do { system("cls"); button: printf("\n\n\n ********学生宿舍信息管理系统********\n\n"); printf(" 1. 创建学生宿舍信息\n\n"); printf(" 2. 打印学生宿舍信息\n\n"); printf(" 3. 查询学生宿舍信息\n\n"); printf(" 4. 修改学生宿舍信息\n\n"); printf(" 5. 删除学生宿舍信息\n\n"); printf(" 6. 学生宿舍信息排序\n\n"); printf(" 0. 退出系统\n\n"); 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("\n 请输入正确的指令!\n"); goto button; } }while(choice!=0); save_file(stu,sum); } int main() { pagedis(); check(); menu(); return 0; }
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持我们。
赞 (0)