最新学生宿舍管理软件C语言源代码(完整版)
宿舍管理系统c语言
#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);}}}。
学生管理系统c语言源代码
int main()
{
initLinkTable(&head);//初始化表头
readStu();//读入源文件
while (1)
{
menu();
system("cls");
}
}
void initLinkTable(studentLinkPoint *p)
int sum(studentLinkPoint);//求和
void avg(studentLinkPoint);//求平均分
void disAvgSum(studentLinkPoint);//显示总分和平均分
char *inputNumber();//专门用来输入一个学生的学号,返回该字符串的指针
char name[20];
char number[18];
int i;
if(temp==0)
{
error("input");
return 0;
}
else
{
temp->student=(studentPint)malloc(sizeof(studentNod));
break;
case 0:
del(head,end);
break;
}
if(c==0)
exit(1);
}
void del(studentLinkPoint p,studentLinkPoint End)
{
studentLinkPoint q;
if(end==head)
printf(" %3.1f %3.1f\n",p->student->sum,p->student->avg);
宿舍管理系统_C语言源代码
#include<stdio.h>struct dorm{int num;int members_num;int Health_score;char member1[10];char member2[10];char member3[10];char member4[10];};struct student{int num;char name[10];int dorm_num;char gender[10];char major[10];char class_name[10];char instructor[10];};static struct dorm dm[100];static struct student st[400];static int d_i=2;static int s_i=2;void pri_dorm(struct dorm d){printf("\n宿舍号:%d\n",d.num);printf("现住人数:%d\n",d.members_num);printf("卫生分数:%d\n",d.Health_score);printf("宿舍成员:\n");if(d.member1[0]!=NULL) printf("%s\n",d.member1);if(d.member2[0]!=NULL) printf("%s\n",d.member2);if(d.member3[0]!=NULL) printf("%s\n",d.member3);if(d.member4[0]!=NULL) printf("%s\n",d.member4);printf("\n");}void pri_student(struct student s){printf("\n学号:%d\n",s.num);printf("姓名:%s\n",);printf("宿舍号:%d\n",s.dorm_num);printf("性别:%s\n",s.gender);printf("班级:%s\n",s.class_name);printf("专业:%s\n",s.major);printf("辅导员:%s\n",s.instructor);printf("\n");}int panduansusherenshu(struct dorm d)//通过此函数,判断宿舍共多少人(宿舍人数最多住四个人){int i=0;if(d.member1[0]!=NULL){i++;}if(d.member2[0]!=NULL){i++;}if(d.member3[0]!=NULL){i++;}if(d.member4[0]!=NULL){i++;}return i;}int panduanxueshengxinxi(struct student s)//判断学生信息是否合法{int i=1;int j=0;int k=0;if(((s.num/100000000)>0)){if(!strcmp(s.gender,"男")||!strcmp(s.gender,"女")){if((s.dorm_num/100)>0){i=0;}}}for(j=0;j<sizeof(dm)/52;j++){if(dm[j].num==s.dorm_num){k=1;break;}}if(k==0) {i=1;}for(j=0;j<sizeof(st)/60;j++){if(st[j].num==s.num) i=1;}for(j=0;j<sizeof(dm)/52;j++){if(dm[j].members_num==4) {i=1;printf("\n宿舍人数已满!\n");}}return i;}void main_interface()//主界面{int i=0;void interface1();void interface2();void interface3();void interface4();void interface5();void interface6();printf("********************************\n");printf("****** 宿舍管理系统******\n");printf("*** 1.查询宿舍信息***\n");printf("*** 2.查询学生信息***\n");printf("*** 3.添加入住学生***\n");printf("*** 4.删减入住学生***\n");printf("*** 5.更改宿舍信息***\n");printf("*** 6.更改学生信息***\n");printf("*** 7.退出系统***\n");printf("********************************\n");printf("请输入操作项:");scanf("%d",&i);switch(i){case 1:system("cls");interface1();break;case 2:system("cls");interface2();break;case 3:system("cls");interface3();break;case 4:system("cls");interface4();break;case 5:system("cls");interface5();break;case 6:system("cls");interface6();break;case 7:system("cls");exit(0);default:system("cls");printf("操作项命令错误,请重新输入!");main_interface();break;}}void interface1()//查找宿舍信息{int i=0;//选项选择int j=0;//记录需要查询的学生学号int k=0;int q=0;printf("\n");printf("进入宿舍信息查询界面:\n");printf("********************************\n");printf("****** 宿舍信息查询******\n");printf("*** 1.进入宿舍查询***\n");printf("*** 2.返回主界面***\n");printf("********************************\n");printf("请输入操作项:");scanf("%d",&i);switch(i){case 1:printf("请输入需要查询宿舍的宿舍号:");scanf("%d",&j);for(k=0;k<sizeof(dm)/52;k++){if(dm[k].num==j){q=1; break;}}if(q==1){system("cls");pri_dorm(dm[k]);printf("\n返回上一界面\n");interface1();}else{system("cls");printf("\n不存在您所查询的宿舍号!");printf("\n返回上一界面\n");interface1();}break;case 2:system("cls");printf("\n");printf("进入主界面:\n");main_interface();break;default :system("cls");printf("\n选项输入错误!\n");printf("\n返回上一界面\n");interface1();break;}}void interface2()//查找学生信息{int i=0;//选项选择int j=0;//记录学生学号int q=0;int k=0;printf("\n");printf("进入学生信息查询界面:\n");printf("********************************\n");printf("****** 学生信息查询******\n");printf("*** 1.进入学生查询***\n");printf("*** 2.返回主界面***\n");printf("********************************\n");printf("请输入操作项:");scanf("%d",&i);switch(i){case 1:printf("请输入需要查询学生的学号:");scanf("%d",&j);for(k=0;k<sizeof(dm)/52;k++){if(st[k].num==j){q=1; break;}}if(q==1){system("cls");pri_student(st[k]);printf("\n返回上一界面\n");interface2();}else{system("cls");printf("\n你查找的学生不存在!");printf("\n返回上一界面\n");interface2();}break;case 2:system("cls");printf("\n");printf("进入主界面:\n");main_interface();break;default:system("cls");printf("\n选项输入错误!\n");printf("\n返回上一界面\n");interface2();break;}}void interface3()//添加入住学生{struct student ss;int j=0;printf("请输入学生的信息:\n");printf("学号:");scanf("%d",&ss.num);printf("姓名:");scanf("%s",&);printf("宿舍号:");scanf("%d",&ss.dorm_num);printf("性别:");scanf("%s",&ss.gender);printf("班级:");scanf("%s",&ss.class_name);printf("专业:");scanf("%s",&ss.major);printf("辅导员:");scanf("%s",&ss.instructor);if(panduanxueshengxinxi(ss)==0){s_i++;st[s_i].num=ss.num;st[s_i].dorm_num=ss.dorm_num;strcat(st[s_i].name,);strcat(st[s_i].gender,ss.gender);strcat(st[s_i].class_name,ss.class_name);strcat(st[s_i].instructor,ss.instructor);strcat(st[s_i].major,ss.major);pri_student(st[s_i]);}else{system("cls");printf("\n\n输入的学生信息有错误,请重新输入!\n\n");interface3();}for(j=0;j<=sizeof(dm)/52;j++){if(dm[j].num==ss.dorm_num) break;}if(dm[j].member1[0]==NULL) strcat(dm[j].member1,);else if(dm[j].member2[0]==NULL) strcat(dm[j].member2,);else if(dm[j].member3[0]==NULL) strcat(dm[j].member3,);else strcat(dm[j].member4,);dm[j].members_num++;system("cls");printf("添加学生成功!\n");printf("\n返回主界面!\n");main_interface();}void interface4()//删除入住学生{int i=0;//存储需要删除学生的学号int j=0;int k=0;int q=0;printf("请输入需要删除的学生学号:\n");scanf("%d",&i);for(j=0;j<sizeof(st)/60;j++){if(st[j].num==i){k=1;break;}}if(k==0){system("cls");printf("不存在需要删除学生!\n");printf("返回上一界面,请重新输入!\n");interface4();}if(k==1){for(q=0;q<sizeof(dm)/52;q++){if(dm[q].num=st[j].dorm_num){dm[q].members_num--;if(!strcmp(dm[q].member1,st[j].name)){dm[q].member1[0]=NULL;strcmp(dm[q].member1," ");}if(!strcmp(dm[q].member2,st[j].name)){dm[q].member2[0]=NULL;strcmp(dm[q].member2," ");}if(!strcmp(dm[q].member3,st[j].name)){dm[q].member3[0]=NULL;strcmp(dm[q].member3," ");}if(!strcmp(dm[q].member4,st[j].name)){dm[q].member4[0]=NULL;strcmp(dm[q].member4," ");}}}st[j].num=0;st[j].name[0]=NULL;strcmp(st[j].name," ");st[j].class_name[0]=NULL;strcmp(st[j].class_name," ");st[j].dorm_num=0;st[j].gender[0]=NULL;strcmp(st[j].gender," ");st[j].instructor[0]=NULL;strcmp(st[j].instructor," ");st[j].major[0]=NULL;strcmp(st[j].major," ");}system("cls");printf("删除学生成功,返回主界面!\n");main_interface();}void interface5()//更改宿舍信息{int i=0;//存储宿舍号int j=0;//储存更改后的分数int k=0;int q=0;printf("请输入需要更改信息的宿舍号:\n");scanf("%d",&i);for(k=0;k<sizeof(dm)/52;k++){if(dm[k].num==i){q=1;break;}}if(q==1){printf("********************************\n");printf("****** 宿舍信息更改******\n");printf("*** 更改卫生分数***\n");printf("********************************\n");while(1){printf("\n%d宿舍卫生分数更改为:\n",i);scanf("%d",&j);if(j>=0&&j<=10) break;else {printf("输入的分数有错误,请重新输入!\n");}}dm[k].Health_score=j;system("cls");printf("更改宿舍信息成功!\n");printf("\n返回主界面:\n");main_interface();}if(q==0){system("cls");printf("输入的宿舍号不存在,请确认后重新输入!\n\n");interface5();}}void interface6()//更改学生信息{int i=0;//存储学生学号int k=0;//判断该学号是否存在int j=0;int q=0;//存储选项struct student ss;printf("请输入需要被更改的学生的学号:\n");scanf("%d",&i);for(j=0;j<sizeof(st)/60;j++){if(st[j].num==i){k=1;break;}}if(k==0){printf("该学号不存在,请确认后重新输入!\n");interface6();} if(k==1){printf("********************************\n");printf("****** 学生信息更改******\n");printf("*** 1.更改姓名***\n");printf("*** 2.更改班级***\n");printf("*** 3.更改专业***\n");printf("*** 4.更改辅导员***\n");printf("********************************\n");printf("\n请输入选项:\n");scanf("%d",&q);switch(q){case 1:printf("请输入改变后的姓名:\n");scanf("%s",);strcpy(st[j].name,);system("cls");printf("\n更改信息成功,返回主界面!\n");main_interface();break;case 2:printf("请输入改变后的班级:\n");scanf("%s",ss.class_name);strcpy(st[j].class_name,ss.class_name);system("cls");printf("\n更改信息成功,返回主界面!\n");main_interface();break;case 3:printf("请输入改变后的专业:\n");scanf("%s",ss.major);strcpy(st[j].major,ss.major);system("cls");printf("\n更改信息成功,返回主界面!\n");main_interface();break;case 4:printf("请输入改变后的辅导员:\n");scanf("%s",ss.instructor);strcpy(st[j].instructor,ss.instructor);system("cls");printf("\n更改信息成功,返回主界面!\n");main_interface();break;default :system("cls");printf("选项输入错误! 返回上一界面!\n");interface6();break;}}}void start(){int j=103;int i=0;dm[0].num=101;dm[0].Health_score=10;dm[0].member1[0]=NULL;strcat(dm[0].member1,"赵钱");dm[0].member2[0]=NULL;dm[0].member3[0]=NULL;dm[0].member4[0]=NULL;dm[0].members_num=panduansusherenshu(dm[0]);dm[1].num=102;dm[1].Health_score=9;dm[1].member1[0]=NULL;strcat(dm[1].member1,"周吴");dm[1].member2[0]=NULL;dm[1].member3[0]=NULL;dm[1].member4[0]=NULL;dm[1].members_num=panduansusherenshu(dm[1]);for(i=2;i<100;i++){dm[i].num=j++;dm[i].members_num=0;dm[i].Health_score=0;dm[i].member1[0]=NULL;dm[i].member2[0]=NULL;dm[i].member3[0]=NULL;dm[i].member4[0]=NULL;}st[0].num=201011011;st[0].name[0]=NULL;strcat(st[0].name,"赵钱");st[0].dorm_num=101;st[0].class_name[0]=NULL;strcat(st[0].class_name,"工商1001");st[0].gender[0]=NULL;strcat(st[0].gender,"女");st[0].major[0]=NULL;strcat(st[0].major,"工商管理");st[0].instructor[0]=NULL;strcat(st[0].instructor,"巴菲特");st[1].num=201011012;st[1].name[0]=NULL;strcat(st[1].name,"周吴");st[1].dorm_num=102;st[1].class_name[0]=NULL;strcat(st[1].class_name,"软件1001");st[1].gender[0]=NULL;strcat(st[1].gender,"女");st[1].major[0]=NULL;strcat(st[1].major,"软件工程");st[1].instructor[0]=NULL;strcat(st[1].instructor,"李开复");for(i=2;i<400;i++){st[i].num=0;st[i].name[0]=NULL;st[i].class_name[0]=NULL;st[i].dorm_num=0;st[i].gender[0]=NULL;st[i].instructor[0]=NULL;st[i].major[0]=NULL;}}int main(){start();printf("************************************************************************\ n");printf(" 宿舍管理系统说明: \n\n");printf(" 该程序现有两人(201011011赵钱、201011012周吴)分别入住在寝室101、102\n\n");printf(" 宿舍号必须为三位数字,如101;学生学号必须为9位数字,如201093046;\n\n");printf(" 添加入住学生时,学生性别只能输入'男'或'女',其他输入视为无效输入!\n\n");printf(" 寝室最多入住人数为4人,添加学生到一宿舍时,该宿舍人数为4人,则提醒错误!\n\n");printf("********************************************************************* ***\n\n");main_interface();return 0;}。
学生宿舍管理软件C语言源代码
一、需求分析该程序是由C语言编写的一个宿舍管理查询软件,其主要功能是实现对学生信息的增加、删除、修改、查询、排序、存储、加载。
其中查询可以分别以姓名、学号、寝室号为关键字查询学生信息。
排序可以分别以学号和寝室号为关键字进行从小到大的排序。
①输入的形式:根据用户所选择的功能,然后再依据程序相应的提示进行输入:选择功能1(添加学生信息):按照从先到后的顺序输入学生姓名(30个字符以内),学生学号(15个字符以内),宿舍号码(整数,范围在0~32767)。
选择功能2(修改学生信息):按照从先到后的顺序输入要修改的学生姓名(30个字符以内),修改后学生的姓名(30个字符以内),修改后学生的学号(15个字符以内),修改后学生的宿舍号(整数,范围在0~32767)。
选择功能3(删除学生信息):输入要删除的学生姓名(30个字符以内)。
选择功能4(以姓名查询学生信息):输入要查找的学生的姓名(30个字符以内)。
选择功能5(以学号查询学生信息):输入要查找的学生的学号(15个字符以内)。
选择功能6(以寝室号查询学生信息):输入寝室号(整数,范围在0~32767)。
②输出的形式:根据用户所选择的功能不同,会有不同的输出:选择功能1(添加学生信息):根据程序的判断会输出添加成功或者添加失败。
选择功能2(修改学生信息):根据程序的判断会输出修改成功或者修改失败。
选择功能3(删除学生信息):根据程序的判断会输出删除成功或者删除失败。
选择功能4(以姓名查询学生信息):根据程序的判断,如果查找成功,则会输出相应的学生信息,反之,则会输出查找失败。
选择功能5(以学号查询学生信息):根据程序的判断,如果查找成功,则会输出相应的学生信息,反之,则会输出查找失败。
选择功能6(以寝室号查询学生信息):根据程序的判断,如果查找成功,则会输出相应的学生信息,反之,则会输出查找失败。
选择功能7,8(以寝室号和学号为关键字进行从小到大的排序):程序会输出排序成功。
学生宿舍管理源代码
printf("\a\a警告:您输入错误,是否重输!(y/n)");
fflush(stdin);
ch1=getchar();
system("cls");
break;
}
} //end switch
}while(ch=='n'|| ch1=='y'); //控制是否要退出系统
printf("****************************** 学生信息插入 **********************************\n");
charu(stu,count); //调用插入函数
count++;
printf("是否继续插入?(y/n)");
printf("请输入第%d个学生的信息\n");
stu[count]=shuru(); //调用输入函数
printf("是否继续(y/n)");
fflush(stdin); // 刷新标准输入缓冲区,把输入缓冲区里的东西丢弃
ch=getchar();
count++;
c=='g')
return "女";
else
return "男";
}
}stu;
/****************************主函数开始**************************/
if(choice3==1) //控制按照学号查找
{
chazhao_number(stu,count); //调用按照学号查找的函数
c语言宿舍管理
c语言宿舍管理以下是一个简单的 C 语言宿舍管理程序示例,用于管理宿舍的入住和退房记录:```c#include <stdio.h>#include <stdlib.h>#include <string.h>#define MAX_HOSTS 100// 宿舍结构体struct Dorm {char name[50];int capacity;int occupied;int* roomNumbers;};// 初始化宿舍结构体void initDorm(struct Dorm* dorm) {strcpy(dorm->name, "");dorm->capacity = 0;dorm->occupied = 0;dorm->roomNumbers = NULL;}// 释放宿舍内存void freeDorm(struct Dorm* dorm) {if (dorm->roomNumbers != NULL) {free(dorm->roomNumbers);}}// 添加宿舍void addDorm(struct Dorm** head, struct Dorm* dorm) {if (*head == NULL) {*head = dorm;} else {struct Dorm* current = *head;while (current->next != NULL) {current = current->next;}current->next = dorm;}}// 打印宿舍信息void printDormInfo(struct Dorm* dorm) {printf("宿舍名称: %s\n", dorm->name);printf("容量: %d\n", dorm->capacity);printf("已入住: %d\n", dorm->occupied);}// 分配宿舍房间号void assignRoomNumbers(struct Dorm* dorm) {if (dorm->roomNumbers == NULL) {dorm->roomNumbers = (int*)malloc(dorm->capacity * sizeof(int)); }for (int i = 0; i < dorm->capacity; i++) {dorm->roomNumbers[i] = i + 1;}}int main() {struct Dorm* head = NULL;// 添加宿舍struct Dorm dorm1;initDorm(&dorm1);strcpy(, "宿舍 1"); dorm1.capacity = 10;addDorm(&head, &dorm1);struct Dorm dorm2;initDorm(&dorm2);strcpy(, "宿舍 2"); dorm2.capacity = 15;addDorm(&head, &dorm2);// 分配宿舍房间号struct Dorm* current = head;while (current != NULL) {assignRoomNumbers(current); current = current->next;}// 打印宿舍信息current = head;while (current != NULL) {printDormInfo(current);current = current->next;}// 释放内存current = head;while (current != NULL) {freeDorm(current);current = current->next;}return 0;}```这个程序创建了一个宿舍管理系统,包括添加宿舍、为宿舍分配房间号以及打印宿舍信息的功能。
C语言宿舍管理系统课设(附源码)
C语言宿舍管理系统课设项目说明本系统基于C语言开发,适用于刚入门的C语言新手项目课设,开发软件采用VC++6.0开发,VS,DEV C++等均可运行。
(书生)项目运行截图代码运行界面截图完整源码#include<stdio.h>#include<stdlib.h>#include<string.h>#define HEAD printf("\t|%-10s%-8s%-9s%-5s%-10s%-5s%-5s%-5s%-5s%-12s%-5s|\n","学号","姓名","专业","班级","公寓名","宿舍","床位","性别","年纪","手机号","级别")/*密码登录管理登录信息*/typedef struct EN{//存用户和密码char userName1[10];char passWorld1[10];}EN;void enter();void encryption(char passWorld[])//加密{int i;for(i=0;i<strlen(passWorld);i++){passWorld[i]+=20;}}void sign_in(char userName[],char passWorld[])//注册{FILE *fp;int flag=0;char userName1[10];char passWorld1[10];printf("\t注册(用户名密码最多9位)\n");printf("\t用户名:");fflush(stdin);gets(userName);printf("\t密码:");gets(passWorld);if((fp=fopen("enter.txt","rt"))==NULL){exit(0);}while(!feof(fp)){fscanf(fp,"%s %s",userName1,passWorld1);if(!strcmp(userName,userName1)){printf("用户名重复\n");flag=1;break;}}fclose(fp);if(flag==1)enter();else{if((fp=fopen("enter.txt","at"))==NULL)exit(0);encryption(passWorld);//加密fprintf(fp,"%s %s\n",userName,passWorld);}fclose(fp);enter();}void alter()//删除不合法用户{FILE *fp;int n=0;EN en[1000];。
宿舍管理系统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的指针以及学生数量的指针。
在函数中,我们可以先输入学生的学号,然后通过遍历数组来找到该学生,最后将该位置清空。
宿舍管理系统源代码
include<stdio.h>include<stdlib.h>include<string.h>typedef struct Student{char name20;char sex5;int age;char institute20;char specialty30;}Student;typedef struct Room{int roomnum;int roomarea;int totalnum;int stunum;Student stu10;Room next;}Room;typedef struct Story{char storynum;Room room;}Story;/-------------------------------------------------------------------------------------------------/ Student StudentCreat int age,char name,char institute,char specialty,char sex {Student Stu;Stu=Student malloc sizeof Student;Stu->age=age;strcpyStu->institute,institute;strcpyStu->name,name;strcpyStu->specialty,specialty;strcpyStu->sex,sex;return Stu;}Room RoomCreat int room_num,int room_area,int total_num,int stu_num{Room R;int i;R=Room malloc sizeof Room;if R return NULL;R->roomnum=room_num;R->roomarea=room_area;R->totalnum=total_num;R->stunum=stu_num;R->next=NULL;return R;}Story StoryCreat{Story S;S=Story malloc sizeof Story;S->room=RoomCreat0,0,0,0;return S;}Story DormCreat{Story S,control;char i;control=Story malloc26sizeof Story;if control return NULL;for i='A';i<='Z';i++{S=StoryCreat;S->storynum=i;controli-'A'=S;}return control;}/-------------------------------------------------------------------------------------------------/ Story StorySearchStory control,char storynum{return control+storynum-'A';}Room RoomSearchRoom R,int room_num{while R->next=NULL{if R->next->roomnum==room_num break;else R=R->next;}return R;Student StudentSearchRoom R,char name{Student p;int i;R=R->next;p=R->stu;for i=0;i<R->stunum;i++{if strcmpp->name,name==0return p;else p++;}return NULL;}/-------------------------------------------------------------------------------------------------/ void RoomInsertStory S,Room R{R->next=S->room->next;S->room->next=R;}void StudentInsertRoom R,Student Stu{R=R->next;R->stuR->stunum=Stu;R->stunum++;}void RoomDeleteRoom R{Room p;R=R->next;p=R;R=R->next;freep;}void StudentDeleteRoom R,Student Stu{R=R->next;Student p;for p=R->stu;Stu<p+R->stunum-1;Stu++Stu=Stu+1;R->stunum--;void RoomRevampRoom R{int i,k;R=R->next;printf"1、房号2、面积3、可容纳人数:\n";printf"要修改那一项:\n";scanf"%d",&i;switch i{case 1:{printf"房号:";scanf"%d",&k;R->roomnum=k;break;}case 2:{printf"面积:";scanf"%d",&k;R->roomarea=k;break;}case 3:{printf"可容纳人数:";scanf"%d",&k;R->totalnum =k;break;}}}void StudentRevampStudent Stu{int i,k;char str30;printf"1、姓名2、性别3、学院4、专业5、年龄:\n";printf"要修改那一项:\n";scanf"%d",&i;switch i{case 1:{printf"姓名:";scanf"%s",str;strcpyStu->name,str;break;}case 2:{printf"性别:";scanf"%s",str;strcpyStu->sex,str;break;}case 3:{printf"学院:";scanf"%s",str;strcpyStu->institute,str;break;}case 4:{printf"专业:";scanf"%s",str;strcpyStu->specialty,str;break;}case 5:{printf"年龄:";scanf"%d",&k;Stu->age =k;break;}}}/-------------------------------------------------------------------------------------------------/ void RoomScanRoom R{int i;Student p;R=R->next;printf"房号:%d\n",R->roomnum;printf"面积:%d\n",R->roomarea;printf"可容纳人数:%d\n",R->totalnum;printf"已住入人数:%d\n",R->stunum;printf"成员:";for i=0;i<R->stunum;i++{p=&R->stui;printf"%s ",p->name;}putchar'\n';}void StudentScanStudent Stu{printf"姓名:%s\n",Stu->name;printf"年龄:%d\n",Stu->age;printf"性别:%s\n",Stu->sex;printf"学院:%s\n",Stu->institute;printf"专业:%s\n",Stu->specialty;}int main{int roomnum,roomarea,totalnum,stunum,age;int event;char name20,institute20,specialty30,sex5;char storynum,judge;Story control;Story S;Room R;Student Stu;control=DormCreat;do{printf"注意\n";printf" 先录入宿舍信息才能录入学生信息\n";printf" 先录入信息才能删除浏览或修改信息\n";printf"\n";printf"\n\n\n 宿舍管理系统\n\n\n";printf"功能选择菜单:\n";printf"1、宿舍信息录入2、学生信息录入3、删除某个宿舍4、删除某个学生\n";printf"5、宿舍信息浏览6、学生信息浏览7、宿舍信息修改8、学生信息修改\n";scanf"%d",&event;switch event{case 1:{{printf"请输入宿舍房间号,房间面积,可容纳人数,已住入人数:以空格隔开\n";fflushstdin;scanf"%c%d %d %d %d",&storynum,&roomnum,&roomarea,&totalnum,&stunum;S=StorySearchcontrol,storynum;R=RoomCreatroomnum,roomarea,totalnum,stunum;RoomInsertS,R;printf"宿舍信息录入成功\n";fflushstdin;printf"是否继续录入宿舍信息Y/N\n";scanf"%c",&judge;}while judge=='Y';break;}case 2:{do{printf"请输入该生要入住的宿舍:\n";fflushstdin;scanf"%c%d",&storynum,&roomnum;fflushstdin;S=StorySearchcontrol,storynum;R=S->room;R=RoomSearchR,roomnum;printf"请输入该生姓名,性别,学院,专业,年龄:以空格隔开\n";scanf"%s%s%s%s",name,sex,institute,specialty;scanf"%d",&age;Stu=StudentCreatage,name,institute,specialty,sex;StudentInsertR,Stu;printf"学生信息录入成功\n";fflushstdin;printf"是否继续录入学生信息Y/N\n";scanf"%c",&judge;}while judge=='Y';break;break;case 3:{do{printf"请输入要删除的宿舍号码:\n";fflushstdin;scanf"%c%d",&storynum,&roomnum;fflushstdin;S=StorySearchcontrol,storynum;R=S->room;R=RoomSearchR,roomnum;RoomDeleteR;printf"宿舍信息删除成功\n";fflushstdin;printf"是否继续删除宿舍信息Y/N\n";scanf"%c",&judge;}while judge=='Y';break;break;}case 4:{do{printf"请输入要删除学生现住宿舍:\n";fflushstdin;scanf"%c%d",&storynum,&roomnum;fflushstdin;S=StorySearchcontrol,storynum;R=S->room;R=RoomSearchR,roomnum;printf"请输入要删除学生的姓名:\n";scanf"%s",name;Stu=StudentSearchR,name;StudentDeleteR,Stu;printf"学生信息删除成功\n";fflushstdin;printf"是否继续删除学生信息Y/N\n";scanf"%c",&judge;}while judge=='Y';break;break;}case 5:{do{printf"请输入要浏览的宿舍号码:\n";fflushstdin;scanf"%c%d",&storynum,&roomnum;fflushstdin;S=StorySearchcontrol,storynum;R=S->room;R=RoomSearchR,roomnum;RoomScanR;fflushstdin;printf"是否继续浏览宿舍Y/N\n";scanf"%c",&judge;}while judge=='Y';break;break;}case 6:{do{printf"请输入要浏览学生的宿舍号码:\n";fflushstdin;scanf"%c%d",&storynum,&roomnum;fflushstdin;S=StorySearchcontrol,storynum;R=S->room;R=RoomSearchR,roomnum;printf"请输入要浏览学生的姓名:\n";scanf"%s",name;Stu=StudentSearchR,name;StudentScanStu;fflushstdin;printf"是否继续浏览学生Y/N\n";scanf"%c",&judge;}while judge=='Y';break;break;}case 7:{do{printf"请输入要修改的宿舍号码:\n";fflushstdin;scanf"%c%d",&storynum,&roomnum;fflushstdin;S=StorySearchcontrol,storynum;R=S->room;R=RoomSearchR,roomnum;RoomRevampR;printf"宿舍信息修改成功\n";fflushstdin;printf"是否继续修改Y/N\n";scanf"%c",&judge;}while judge=='Y';break;break;}case 8:{do{printf"请输入要修改学生的宿舍号码:\n";fflushstdin;scanf"%c%d",&storynum,&roomnum;fflushstdin;S=StorySearchcontrol,storynum;R=S->room;R=RoomSearchR,roomnum;printf"请输入要修改学生的姓名:\n";scanf"%s",name;Stu=StudentSearchR,name;StudentRevampStu;printf"学生信息修改成功\n";fflushstdin;printf"是否继续修改Y/N\n";scanf"%c",&judge;}while judge=='Y';break;break;}}fflushstdin;printf"是否继续其他操作Y/N\n";scanf"%c",&judge;}while judge=='Y';system"pause";}。
最新学生宿舍管理软件C语言源代码(完整版)
char S_class[31]; //
学生班级
char S_number[16]; // 学生学号
int D_number;
// 学生所在寝室的宿舍号
char S_address[500]; //
学生地址
int S_phone[20]; //
学生电话号码
int Total;
// 学生总数
}Student[M],St;
if (!flag) printf( " 你所要删除的学生在表中不存在! " );
else {
for (i=flag;i<S->Total;i++) {
j=i+1; strcpy(S[i].S_name,S[j].S_name); strcpy(S[i].S_number,S[j].S_number); S[i].D_number=S[j].D_number; } (S->Total)--; dirty=1; printf( " 删除成功 !" ); }
精品文档
精品文档
printf( "\n\n" );
}
// 显示所有学生信息函数
void Display_All(Student S)
{
int i;
printf( " 全体学生信息如下 :\n" );
printf( " 学生姓名
学生班级
for (i=1;i<=S->Total;i++)
精品文档
源程序代码:
#include <stdio.h> #include <string.h> #include <stdlib.h>
C语言宿舍管理系统课设(附源码)
C语言宿舍管理系统课设项目说明本系统基于C语言开发,适用于刚入门的C语言新手项目课设,开发软件采用VC++6.0开发,VS,DEV C++等均可运行。
(书生)项目运行截图代码运行界面截图完整源码#include<stdio.h>#include<stdlib.h>#include<string.h>#define HEAD printf("\t|%-10s%-8s%-9s%-5s%-10s%-5s%-5s%-5s%-5s%-12s%-5s|\n","学号","姓名","专业","班级","公寓名","宿舍","床位","性别","年纪","手机号","级别")/*密码登录管理登录信息*/typedef struct EN{//存用户和密码char userName1[10];char passWorld1[10];}EN;void enter();void encryption(char passWorld[])//加密{int i;for(i=0;i<strlen(passWorld);i++){passWorld[i]+=20;}}void sign_in(char userName[],char passWorld[])//注册{FILE *fp;int flag=0;char userName1[10];char passWorld1[10];printf("\t注册(用户名密码最多9位)\n");printf("\t用户名:");fflush(stdin);gets(userName);printf("\t密码:");gets(passWorld);if((fp=fopen("enter.txt","rt"))==NULL){exit(0);}while(!feof(fp)){fscanf(fp,"%s %s",userName1,passWorld1);if(!strcmp(userName,userName1)){printf("用户名重复\n");flag=1;break;}}fclose(fp);if(flag==1)enter();else{if((fp=fopen("enter.txt","at"))==NULL)exit(0);encryption(passWorld);//加密fprintf(fp,"%s %s\n",userName,passWorld);}fclose(fp);enter();}void alter()//删除不合法用户{FILE *fp;int n=0;EN en[1000];fp=fopen("enter.txt","rt");if(fp==NULL){printf("\t打开文件失败\n");exit(0);}while(!feof(fp)){fscanf(fp,"%s %s",en[n].userName1,en[n].passWorld1);n++;}//printf("大小%d\n",--n);printf("\t%-8s\t%-8s\n","用户名","密码");int i;for(i=0;i<n;i++){printf("\t%-8s\t%-8s\n",en[i].userName1,en[i].passWorld1);}fclose(fp);printf("\t输入你要删除的用户名\n");printf("\t用户名:");char ch[10];printf("\t");scanf("%s",ch);for(i=0;strcmp(ch,en[i].userName1);i++){}int k=i;for(i=k;i<n-1;i++){en[i]=en[i+1];}n--;// for(i=0;i<n;i++)// {// printf("%-8s\t%-8s\n",en[i].userName1,en[i].passWorld1); // }fp=fopen("enter.txt","wt");if(fp==NULL){printf("\t打开文件失败\n");exit(0);}for(i=0;i<n;i++){fprintf(fp,"%s %s\n",en[i].userName1,en[i].passWorld1);}fclose(fp);}void enter() //登录入口{printf("\t=================================\n");printf("\t|\t登录:\t\t\t|\n");printf("\t=================================\n");FILE *fp;int i;printf("\t1.管理员\t2.登录\n");char userName[10];char passWorld[10];char userName1[10];char passWorld1[10];int choice;printf("\t");scanf("%d",&choice);int flag=0;switch(choice){case 1:{ //管理员,注册用户和删除char adm[10];printf("\t输入权限码\n");printf("\t");scanf("%s",adm);if(strcmp(adm,"12")){printf("\t权限码错误\n");enter();}printf("\t");printf("1.注册\t2.修改\n");int j;printf("\t");scanf("%d",&j);switch(j){case 1:{sign_in(userName,passWorld);break;}case 2:{int flag1=0;do{alter();flag1=0;printf("\t是否继续删除:1.是 2.否\n");printf("\t");scanf("%d",&flag1);}while(flag1==1);enter();break;}default:{break;}}break;}case 2:{ //用户登录printf("\t登录\n");printf("\t用户名:");fflush(stdin);printf("\t");gets(userName);printf("\t密码:");printf("\t");gets(passWorld);if((fp=fopen("enter.txt","rt"))==NULL){exit(0);}while(!feof(fp)){fscanf(fp,"%s %s",userName1,passWorld1);encryption(passWorld);//加密if(!strcmp(userName,userName1)&&!strcmp(passWorld,passWorld1)) {flag=1;break;}}if(flag==0){printf("\t输入用户名密码不匹配或者错误\n");enter();}printf("\t成功\n");break;}default:{printf("输入选择不符合格式\n");break;}}}/*存储数据操作数据*/typedef struct stu{ //宿舍信息char dorm[50];int dorm_num;int dorm_num_id;char id[10];char name[10];int banji;char major[20];int age;int enUniversity;char number[12];char sex[3];struct stu *next;}stu;void print(stu *head);void interface()//主界面{printf("\n\n");printf("\t---------------------------------------------------------\n");printf("\t|\t\t欢迎使用宿舍信息管理系统\t\t|\n");printf("\t---------------------------------------------------------\n");/*数据录入*/printf("\t|\t\t\t1-录入数据\t\t\t|\n");/*数据增删改查*/printf("\t|\t\t\t2-数据增加\t\t\t|\n");printf("\t|\t\t\t3-数据删除\t\t\t|\n");printf("\t|\t\t\t4-数据修改\t\t\t|\n");printf("\t|\t\t\t5-数据查询\t\t\t|\n");/*数据统计*/printf("\t|\t\t\t6-数据统计\t\t\t|\n");/*报表*/printf("\t|\t\t\t7-数据报表\t\t\t|\n");printf("\t---------------------------------------------------------\n");}int find_id(char id[],stu *head)//学号查重,重复返回0,否则1{stu *i;for(i=head->next;i!=NULL;i=i->next){if(strcmp(id,i->id)==0){printf("\t学号重复\n");return 0;}}return 1;}int find_check(stu *head,stu *p) //检查宿舍是否满员,符合返回1,不符合返回0 {//print(head); //测试//printf("进入\n");stu *i;for(i=head->next;i!=NULL;i=i->next){if(!strcmp(p->dorm,i->dorm)&&(p->dorm_num_id==i->dorm_num_id)&&(p->do rm_num==i->dorm_num)){printf("\t宿舍信息重复\n");return 0;}}return 1;}stu *creat()//创建链表{stu *head,*end,*p;char id[10];head=NULL;head=(stu*)malloc(sizeof(stu));head->next=NULL;end=head;printf("\t输入学号:");fflush(stdin);gets(id);while(strlen(id)>0){if(find_id(id,head))//学号查重,重复返回0,否则1{p=(stu*)malloc(sizeof(stu));strcpy(p->id,id);printf("\t输入姓名:");gets(p->name);printf("\t输入公寓名称:");scanf("%s",p->dorm);printf("\t输入宿舍名称:");scanf("%d",&p->dorm_num);printf("\t输入床位号:");scanf("%d",&p->dorm_num_id);if(find_check(head,p)) //检查宿舍是否满员,符合返回1,不符合返回0{printf("\t手机号:");fflush(stdin);gets(p->number);printf("\t年龄:");scanf("%d",&p->age);printf("\t性别:");scanf("%s",p->sex);printf("\t专业班级:");scanf("%s %d",p->major,&p->banji);printf("\t输入入学年份:");scanf("%d",&p->enUniversity);end->next=p;end=p;p->next=NULL;}}printf("\t输入学号:");fflush(stdin);gets(id);}return head;}void print(stu *head)//链表打印输出{stu *i;for(i=head->next;i!=NULL;i=i->next){printf("\t|%-10s%-8s%-9s%-5d%-10s%-5d%-5d%-5s%-5d%-12s%-5d|\n",i->id,i-> name,i->major,i->banji,i->dorm,i->dorm_num,i->dorm_num_id,i->sex,i->age,i->numb er,i->enUniversity);}}stu *write_linked() //文件生成链表{FILE *fp;fp=fopen("student.txt","rt");stu *i;stu *head;head=NULL;head=(stu*)malloc(sizeof(stu));stu *end,*p;end=head;while(!feof(fp)){p=(stu*)malloc(sizeof(stu));fread(p,sizeof(stu),1,fp);fgetc(fp);end->next=p;end=p;p->next=NULL;}fclose(fp);return head;}void write_file(stu *head) //用链表,生成文件{FILE *fp;fp=fopen("student.txt","wt");stu *i;for(i=head->next;i!=NULL;i=i->next){fwrite(i,sizeof(stu),1,fp);if(i->next!=NULL)fputc('\n',fp);}fclose(fp);}void header()//数据表头{printf("\t---------------------------------------------------------------------------------\n");HEAD;printf("\t---------------------------------------------------------------------------------\n"); }void exchange_num(int *x,int *y)//交换int{int t=*x;*x=*y;*y=t;}void exchange_string(char a[],char b[])//交换字符串{char t[20];strcpy(t,a);strcpy(a,b);strcpy(b,t);}void exchange(stu *ec1,stu *ec2) //交换stu结构体类型{exchange_num(&ec1->age,&ec2->age);exchange_num(&ec1->banji,&ec2->banji);exchange_string(ec1->dorm,ec2->dorm);exchange_num(&ec1->dorm_num,&ec2->dorm_num);exchange_num(&ec1->dorm_num_id,&ec2->dorm_num_id);exchange_string(ec1->id,ec2->id);exchange_num(&ec1->enUniversity,&ec2->enUniversity);exchange_string(ec1->major,ec2->major);exchange_string(ec1->name,ec2->name);exchange_string(ec1->number,ec2->number);exchange_string(ec1->sex,ec2->sex);}void sort(stu *head) //根据公寓宿舍床位排序{stu *i,*j;for(i=head->next;i!=NULL;i=i->next){for(j=i->next;j!=NULL;j=j->next){if(strcmp(i->dorm,j->dorm)>0){exchange(i,j);}}}for(i=head->next;i!=NULL;i=i->next){for(j=i->next;j!=NULL;j=j->next){if(!strcmp(i->dorm,j->dorm)&&i->dorm_num>j->dorm_num){exchange(i,j);}}}for(i=head->next;i!=NULL;i=i->next){for(j=i->next;j!=NULL;j=j->next){if(strcmp(i->dorm,j->dorm)==0&&i->dorm_num==j->dorm_num&&i->dorm_nu m_id>j->dorm_num_id){exchange(i,j);}}}}void add(stu *head)//添加数据{stu *end;for(end=head->next;end->next!=NULL;end=end->next){}stu *p;char id[20];printf("\t输入学号:");fflush(stdin);gets(id);while(strlen(id)>0){if(find_id(id,head))//学号查重,重复返回0,否则1{p=(stu*)malloc(sizeof(stu));p->next=NULL;strcpy(p->id,id);printf("\t输入姓名:");gets(p->name);printf("\t输入公寓名称:");scanf("%s",p->dorm);printf("\t输入宿舍名称:");scanf("%d",&p->dorm_num);printf("\t输入床位号:");scanf("%d",&p->dorm_num_id);if(find_check(head,p)) //检查宿舍是否满员,符合返回1,不符合返回0{printf("\t手机号:");fflush(stdin);gets(p->number);printf("\t年龄:");scanf("%d",&p->age);printf("\t性别:");scanf("%s",p->sex);printf("\t专业班级:");scanf("%s %d",p->major,&p->banji);printf("\t输入入学年份:");scanf("%d",&p->enUniversity);end->next=p;end=p;}}printf("\t输入学号:");fflush(stdin);gets(id);}printf("\t结束\n");}void dele(stu *head)//按学号删除数据{printf("\t输入你要删除的学号:");char id[20];fflush(stdin);gets(id);stu *end1;//倒数第二个stu *i;while(strlen(id)>0){for(end1=head->next;end1->next->next!=NULL;end1=end1->next){}i=head;while((i=i->next)!=NULL){if(strcmp(id,i->id)==0){exchange(i,end1->next);free(end1->next);end1->next=NULL;sort(head);printf("\t成功\n");break;}else if(i->next==NULL){printf("\t->未找到相匹配的学号<-\n");}}printf("\t输入你要删除的学号:");gets(id);}}void modify(stu *head)//按学号修改数据{char flag[5];printf("\t输入你要修改的学号:");char id[20];char new_id[20];fflush(stdin);gets(id);stu *i;stu *k;k=(stu*)malloc(sizeof(stu));k->next=NULL;while(strlen(id)>0){i=head;while((i=i->next)!=NULL){if(strcmp(id,i->id)==0){printf("\t是否修改学号(yes/no):") ;gets(flag);if(strcmp(flag,"yes")==0){printf("\t输入修改的学号:");gets(new_id);if(find_id(new_id,head)||strcmp(id,new_id)==0){strcpy(k->id,new_id);}else{printf("\t新学号重复");break;}}else{strcpy(k->id,i->id);}printf("\t输入姓名:");gets(k->name);printf("\t输入公寓名称:");scanf("%s",k->dorm);printf("\t输入宿舍名称:");scanf("%d",&k->dorm_num);printf("\t输入床位号:");scanf("%d",&k->dorm_num_id);if(find_check(head,k)||(!strcmp(k->dorm,i->dorm)&&i->dorm_num==k->dorm_n um&&i->dorm_num_id==k->dorm_num_id)) //检查宿舍是否满员,符合返回1,不符合返回0{printf("\t手机号:");fflush(stdin);gets(k->number);printf("\t年龄:");scanf("%d",&k->age);printf("\t性别:");scanf("%s",k->sex);printf("\t专业班级:");scanf("%s %d",k->major,&k->banji);printf("\t输入入学年份:");scanf("%d",&k->enUniversity);exchange(i,k);}}else if(i->next==NULL){printf("\t->未找到相匹配的学号<-\n");}}printf("\t输入你要修改的学号:");fflush(stdin);gets(id);}free(k);}void interface1()//数据查询子界面{printf("\t\t------------------\n");printf("\t\t|1.按学号查询|\n");printf("\t\t|2.按姓名查询|\n");printf("\t\t|3.按公寓宿舍查询|\n");printf("\t\t------------------\n");}void lookup_id(stu *head)//按学号查找{char id[20];printf("\t输入学号:");fflush(stdin);gets(id);stu *i;while(strlen(id)>0){i=head;while((i=i->next)!=NULL){if(strcmp(id,i->id)==0){header();printf("\t|%-10s%-8s%-9s%-5d%-10s%-5d%-5d%-5s%-5d%-12s%-5d|\n",i->id,i-> name,i->major,i->banji,i->dorm,i->dorm_num,i->dorm_num_id,i->sex,i->age,i->numb er,i->enUniversity);printf("\t---------------------------------------------------------------------------------\n");break;}else if(i->next==NULL){printf("\t未找到相应学号\n");}}printf("\t输入学号:");fflush(stdin);gets(id);}}void lookup_name(stu *head)//按姓名查找{char name[20];printf("\t输入姓名:");fflush(stdin);gets(name);stu *i;int flag;//判断是否找到数据,1找到,0枚找到int flag1;//判断是否输出表头,1输出,0不输出flag1=1;while(strlen(name)>0){ flag=0;i=head;while((i=i->next)!=NULL){if(strcmp(name,i->name)==0){if(flag1==1){header();flag1=0;}printf("\t|%-10s%-8s%-9s%-5d%-10s%-5d%-5d%-5s%-5d%-12s%-5d|\n",i->id,i-> name,i->major,i->banji,i->dorm,i->dorm_num,i->dorm_num_id,i->sex,i->age,i->numb er,i->enUniversity);flag=1;}else if(i->next==NULL&&flag==0){printf("\t未找到相应姓名\n");}}printf("\t---------------------------------------------------------------------------------\n");printf("\n");printf("\t输入姓名:");fflush(stdin);gets(name);}}void lookup_dorm_num(stu *head)//按公寓宿舍查找{int num=0;char dorm[20];printf("\t输入公寓和宿舍号:");scanf("%s %d",dorm,&num);stu *i;int flag;//判断是否找到数据,1找到,0枚找到int flag1;//判断是否输出表头,1输出,0不输出flag1=1;while(strlen(dorm)>0&&num!=0){ flag=0;i=head;while((i=i->next)!=NULL){if(num==i->dorm_num&&strcmp(dorm,i->dorm)==0){if(flag1==1){header();flag1=0;}printf("\t|%-10s%-8s%-9s%-5d%-10s%-5d%-5d%-5s%-5d%-12s%-5d|\n",i->id,i->name,i->major,i->banji,i->dorm,i->dorm_num,i->dorm_num_id,i->sex,i->age,i->numb er,i->enUniversity);flag=1;}else if(i->next==NULL&&flag==0){printf("\t未找到相应宿舍号\n");}}printf("\t---------------------------------------------------------------------------------\n");printf("\n");num=0;printf("\t输入公寓和宿舍号:");scanf("%s %d",dorm,&num);}}void son_operation(stu *head)//查询操作选项表{printf("\t输入选项(0退出):");int choice;scanf("%d",&choice);if(choice==0){return;}switch(choice){case 1:{lookup_id(head);//按id查询break;}case 2:{lookup_name(head);//按姓名查询break;}case 3:{lookup_dorm_num(head);//按公寓宿舍查询break;}default :{printf("\t->输入格式有误<-\n");break;}}}void son_statistical()//统计操作表子目录{printf("\t\t----------------\n");printf("\t\t|1.统计总人数|\n");printf("\t\t|2.统计单个公寓|\n");printf("\t\t|3.统计公寓宿舍|\n");printf("\t\t----------------\n");}void statistical_total(stu *head)//统计总人数{stu *i;int n=0;for(i=head->next;i!=NULL;i=i->next){n++;}printf("\t->共%d人<-\n",n);}void statistical_dorm(stu *head)//统计单个公寓{int n=0;char dorm[20];printf("\t输入公寓:");fflush(stdin);gets(dorm);stu *i;while(strlen(dorm)>0){i=head;n=0;while((i=i->next)!=NULL){if(strcmp(dorm,i->dorm)==0){n++;}}printf("\t->该公寓共%d人<-\n",n);printf("\t输入公寓:");fflush(stdin);gets(dorm);}}void statistical_dorm_num(stu *head)//统计公寓宿舍{int num=0;int n;char dorm[20];printf("\t输入公寓和宿舍号:");scanf("%s %d",dorm,&num);stu *i;while(strlen(dorm)>0&&num!=0){ n=0;i=head;while((i=i->next)!=NULL){if(num==i->dorm_num&&strcmp(dorm,i->dorm)==0){n++;}}printf("\t->该宿舍工%d人<-\n",n);num=0;printf("\t输入公寓和宿舍号:");scanf("%s %d",dorm,&num);}}void statistical_operation(stu *head) //统计操作选项表{printf("\t输入选项(0退出):");int choice;scanf("%d",&choice);if(choice==0){return;}switch(choice){case 1:{statistical_total(head);//统计总人数break;}case 2:{statistical_dorm(head);//统计单个公寓break;}case 3:{statistical_dorm_num(head);//统计公寓宿舍break;}default :{printf("\t->输入格式有误<-\n");break;}}}int main(){enter();//登录system("cls");printf("\t登陆成功\n");int choice;while(1){interface();stu *head;printf("\t输入1~7:");scanf("%d",&choice);switch(choice){case 1:{//录入信息head=creat();//创建链表//print(head);write_file(head);//写入文件break;}case 2:{//增加head=write_linked();add(head);sort(head);write_file(head);break;}case 3:{ //按学号删除head=write_linked();dele(head);write_file(head);break;}case 4:{//改按学号head=write_linked();modify(head);write_file(head);break;}case 5:{//查,按姓名,宿舍,学号interface1();//子目录head=write_linked();son_operation(head);break;}case 6:{ //统计,总人数,每个宿舍人数,一个楼人数head=write_linked();son_statistical();statistical_operation(head);//statistical_date();break;}case 7:{//报表head=write_linked();header();sort(head);print(head);printf("\t---------------------------------------------------------------------------------\n");break;}default :{//system("cls");printf("\t->输入有误,重新输入<-\n");break;}}printf("\t按任意键继续");fflush(stdin);getchar();system("cls");}}。
学生管理系统c语言源代码
学生管理系统c语言源代码学生管理系统c语言源代码#include stdio.h#include dos.h#include string.h#include stdlib.h#include malloc.h#define SIZE 8struct student{char name;char num;int score;float ave;struct student *next;}stu[SIZE],temp,s;void shuru(){int i,j,sum,length,flag=1,a;FILE *fp;while(flag==1){printf(“Define a rangeclass number:");scanf("%d",printf("Input the total number of the class(a):"); scanf("%d",length);if(lengtha)flag=0;}for(i=0;ilength;i++){printf("\n请输入学生的信息:");printf("\n输入姓名:");scanf("%s",stu[i].name);printf("\n输入序号.:");scanf("%s",stu[i].num);printf("\n输入成绩:\n");sum=0;for(j=0;jj++){printf("score %d:",j+1);scanf("%d",stu[i].score[j]);sum+=stu[i].score[j];}stu[i].ave=sum/3.0;}学生管理系统c语言源代码fp=fopen("stu1.txt","w");for(i=0;ilength;i++)if(fwrite(stu[i],sizeof(struct student),1,fp)!=1)printf("File write error\n");fclose(fp);fp=fopen("stu1.txt","r");printf("\name\ NO. score1 score2 score3 sum ave\n");for(i=0;ilength;i++){fread(stu[i],sizeof(struct student),1,fp);printf("%3s%5s%7d%7d%7d%7d%10.2f\n",stu[i].name,stu[i].num,stu[i ].score,stu[i].score,stu[i].score,sum=stu[i].score+stu[i].score+stu[i].score,stu[i].ave);}}void chaxun(){ FILE *fp, *fp1;char n,name;int i,j,k,t,m,flag=1;if((fp=fopen("stu1.txt","r"))==NULL){printf("Can not open the file.");exit(0);}printf("\noriginal data:\n");k=i;printf("\nPlease select the menu(1.number ):"); scanf("%d",switch(m){case 1:printf("\nchaxun number:");scanf("%s",n);for(flag=1,i=0;ii++){if(strcmp(n,stu[i].num)==0){j=i;flag=0;break;}}break;case 2:printf("\nchaxun name:");scanf("%s",name);for(flag=1,i=0;ii++){if(strcmp(name,stu[i].name)==0){j=i;flag=0;break;学生管理系统c语言源代码}}}if(!flag){printf("\nYou can find:\n");fp1=fopen("stu2.txt","w");printf(" name NO. score1 score2 score3ave\n");fwrite(stu[j],sizeof(struct student),1,fp1);printf("%-15s%11s%7d%7d%7d%10.2f",stu[j].name,stu[j].num,stu[j].score,stu[j].score,stu[j].score,stu[j].ave);}else printf("\nNot found!");fclose(fp);fclose(fp1);}xiugai(){ int a;printf("\nplease select the menu(1.CHARU 2.__ ):");scanf("%d",switch(a){case 1:Insert(); break;case 2:Delete(); break;}}Insert(){ FILE *fp;int i,j,t,n;printf("\nNO.:");scanf("%s",s.num);printf("name:");scanf("%s",);printf("score1,score2,score3:");scanf("%d,%d,%d",s.score,s.score,s.score);s.ave=(s.score+s.score+s.score)/3.0;if((fp=fopen("stu1.txt","r"))==NULL){printf("Can not open the file.");exit(0);}printf("\noriginal data:\n");for(i=0;fread(stu[i],sizeof(struct student),1,fp)!=0;i++) {printf("\n%-15s%11s",stu[i].name,stu[i].num);for(j=0;jj++)学生管理系统c语言源代码printf("%7d",stu[i].score[j]);printf("%10.2f",stu[i].ave);}fclose(fp);n=i;for(t=0;stu[t].aves.avett++);printf("\nnow:\n");fp=fopen("stu1.txt","w");for(i=0;ii++){fwrite(stu[i],sizeof(struct student),1,fp);printf("\n%-15s%11s",stu[i].name,stu[i].num);for(j=0;jj++)printf("%7d",stu[i].score[j]);printf("%10.2f",stu[i].ave);}fwrite(s,sizeof(struct student),1,fp);printf("\n%-15s%11s%7d%7d%7d%10.2f",,s.num,s.score,s.score, s.score,s.ave);for(i=t;ii++){fwrite(stu[i],sizeof(struct student),1,fp);printf("\n%-15s%11s",stu[i].name,stu[i].num);for(j=0;jj++)printf("%7d",stu[i].score[j]);printf("%10.2f",stu[i].ave);}fclose(fp);}Delete(){ FILE *fp;int i,j,t,n,flag;char number;if((fp=fopen("stu1.txt","rb"))==NULL){printf("Can not open the file.");exit(0);}printf("\noriginal data:");for(i=0;fread(stu[i],sizeof(struct student),1,fp)!=0;i++) {printf("\n%-15s%11s",stu[i].name,stu[i].num);for(j=0;jj++)printf("%7d",stu[i].score[j]);printf("%10.2f",stu[i].ave);}fclose(fp);n=i;学生管理系统c语言源代码printf("\nInput number deleted:");scanf("%s",number);for(flag=1,i=0;flagii++){if(strcmp(number,stu[i].num)==0){for(t=i;tt++){strcpy(stu[t].num,stu[t+1].num);strcpy(stu[t].name,stu[t+1].name);for(j=0;jj++)stu[t].score[j]=stu[t+1].score[j];stu[t].ave=stu[t+1].ave;}n=n-1;elseprintf("\n Not found!");printf("\nNow,the content of file:\n");fp=fopen("stu1.txt","wb");for(i=0;ii++)fwrite(stu[i],sizeof(struct student),1,fp);fclose(fp);fp=fopen("stu1.txt","r");for(i=0;fread(stu[i],sizeof(struct student),1,fp)!=0;i++)printf("%-15s%11s%7d%7d%7d%10.2f\n",stu[i].name,stu[i].num,stu[i].score, stu[i].score,stu[i].score,stu[i].ave);fclose(fp);}paixu(){FILE *fp;int i,j,n;if((fp=fopen("stu1.txt","r"))==NULL){printf("Can not open the file.");exit(0);}printf("\nfile'stu1.txt':");for(i=0;fread(stu[i],sizeof(struct student),1,fp)!=0;i++) {printf("\n%-15s%11s",stu[i].name,stu[i].num);for(j=0;jj++)printf("%7d",stu[i].score[j]);printf("%10.2f",stu[i].ave);}fclose(fp);n=i;for(i=0;ii++)for(j=i+1;jj++)学生管理系统c语言源代码if(stu[i].avestu[j].ave){temp=stu[i];stu[i]=stu[j];stu[j]=temp;}printf("\nnow:");fp=fopen("stu1.txt","w");for(i=0;ii++){fwrite(stu[i],sizeof(struct student),1,fp);printf("\n%-15s%11s",stu[i].name,stu[i].num);tongji(){ FILE *fp;int i,j,k,labe1,b;int a5=0;int a6=0;int a7=0;int a8=0;int a9=0; int a10=0; float t;if((fp=fopen("stu1.txt","r"))==NULL){printf("Can not open the file.");exit(0);}printf("\nfile'stu1.txt':");for(i=0;fread(stu[i],sizeof(struct student),1,fp)!=0;i++){printf("\n%-15s%11s",stu[i].name,stu[i].num); for(j=0;jj++)printf("%7d",stu[i].score[j]);printf("%10.2f",stu[i].ave);}fclose(fp);k=i;for(i=0;ii++){labe1=0;if(stu[i].ave60){labe1++;t=labe1/(float)k*100;}}printf("\nbujigelv:");printf("%f%",t);printf("\n");for(j=0;jj++){a5=0;a6=0;a7=0;a8=0;a9=0;a10=0;k=i;printf("kemu is %d:\n",j);for(i=0;ii++)学生管理系统c语言源代码{b=stu[i].score[j]/10;if(b6)a5++;elseif(b=6b7)a6++;elseif(b=7b8)a7++;elseif(b=8b9)a8++;if(b=9b10)a9++;elseif(b==10)a10++;}printf(" 不及格is %d\n",a5);printf(" 60--69 is %d\n",a6);printf(" 70--79 is %d\n",a7);printf(" 80--89 is %d\n",a8);printf(" 90--99 is %d\n",a9);printf(" 100 is %d\n",a10);}}main(){int a;printf(" ____\n"); printf(" 欢迎进入学生成绩管理系统\n");printf(" ____\n"); while(1){printf("\n选择菜单:\n");printf("\n");printf(" 1.输入 2.查询 3.排序 4.修改 5.统计 6.退出\n"); scanf("%d",switch(a){case 1: shuru();break;case 2: chaxun(); break;case 3: paixu(); break;case 4: xiugai(); break;学生管理系统c语言源代码case 5: tongji();break; case 6: exit(0); }。
C语言课程设计——学生管理系统源代码
C语言课程设计——学生管理系统源代码#include〈stdio。
h>#include〈stdlib。
h〉#include<string。
h〉#include〈conio.h>#define MY1 printf(”学号\t姓名\t性别\t年龄\t生日”)#define MY2 printf(”\n%d %6s %4s\t%2d %8d%2d%2d \n",s[i].num,s[i].name,s[i]。
sex,s[i]。
age,s[i]。
a。
year,s[i].a。
month,s[i].a.day)#define MY3 printf(”家庭住址联系方式高数英语大物总成绩")#define MY4 printf(”\n%4s %4s %2d %2d %2d %2d\n”,s[i]。
address,s[i]。
tel,s[i].c。
gao,s[i]。
c.ying,s[i].c.wu,s[i].c.total)#define MAX 30int i;int sum;/*时间结构体类型*/struct date{int year;int month;int day;}a;/*学生成绩结构体类型*/struct score{int gao;int ying;int wu;int total;}c;/*学生信息结构体类型*/struct s_message{int num;char name[20];char sex[5];int age;struct date a;char address[50];char tel [11];struct score c;}s[MAX];/*保存学生信息模块*/int i;FILE*fp;if((fp=fopen(”D:\\s。
txt",”wb”))==NULL){printf(”reading file is wrong!\n”);return;}for (i=0;i<sum;i++){if(fwrite(&s[i],sizeof(struct s_message),1,fp)!=1)printf(”writing file is wrong!\n”);}fclose(fp);}/*读取学生信息模块*/int read_message(){FILE *fp;int i=0;if((fp=fopen("D:\\s。
学生宿舍管理软件C语言源代码(完整版)
getchar();
printf(请输入学生班级(30个字符以内):”);
scanf("%s",S[flag].S_class);
getchar();
printf("请输入学生的学号(15个字符以内):");
scanf( "%s" ,S[flag].S_number);
printf(请输入学生电话号码:”;
scanf("%s",&S[flag]. S_phone);
getchar();
dirty=1;
printf("修改成功!\n");
}
putchar( '\n');
}
//删除学生信息
void Delete(Student S)
{
int i,j;
int flag=0; //用来判断表中是否存在所要删除的学生的信息
scanf( "%d",&S[S->Total].D_number);
getchar();
printf("请输入学生地址:");
scanf("%s",S[S->Total].S_address);
getchar();
printf(请输入学生电话号码:”;
scanf("%s",&S[S->Total]. S_phone);
char S_class[31];//学生班级
char S_number[16];//学生学号
int D_number;//学生所在寝室的宿舍号char S_address[500];//学生地址
C语言学生宿舍管理系统代码(可运行)
C语⾔学⽣宿舍管理系统代码(可运⾏)#include<stdio.h>#include<stdlib.h>#include<conio.h>#include<string.h>#include<windows.h>#include <malloc.h>#include<dos.h>#define len sizeof(struct dorminfo)#define Max 100int a[Max]={0};int length;void showmenu();void processmenu();void create();void display();void disbed();void modify();void del();void save();void read();typedef struct{int dormno;int bedno;int isstay;}bedinfo;struct dorminfo{bedinfo bed;int stuno;char name[20];char stucla[20];int year;int month;struct dorminfo *next;};struct dorminfo *head=NULL,*p1,*p2,*p3;void showmenu(){printf("\n\n\n\t\t 欢迎进⼊学⽣宿舍管理系统\n");printf("\t\t*********************************\n");printf("\t\t1.输⼊床位信息\n");printf("\t\t2.根据学号,显⽰学⽣住宿信息\n");printf("\t\t3.根据宿舍号,显⽰住宿信息\n");printf("\t\t4.根据宿舍号、床位号,修改住宿信息\n");printf("\t\t5.根据宿舍号、床位号,删除住宿信息\n");printf("\t\t6.保存学⽣宿舍信息\n");printf("\t\t7.从⽂件读⼊学⽣信息\n");printf("\t\t8.退出 \n");printf("\t\t********************************\n") ;}void processmenu(){int caidan;printf("请输⼊您的选项<1~8>:");scanf("%d",&caidan);if(caidan>8||caidan<0){printf("对不起,您输⼊的选项有误,请重新输⼊!");scanf("%d",&caidan);}switch(caidan){case 2:display();break;case 3:disbed();break;case 4:modify();break;case 5:del();break;case 6:save();break;case 7:read();break;case 8:exit(0);}}void create(){int j;char ch;length=0;p1=(struct dorminfo *)malloc(len);if(head==NULL)head=p1;printf("开始输⼊床位信息....\n");Sleep(500);do{p2=(struct dorminfo *)malloc(len);printf("请输⼊宿舍号:");scanf("%d",&p2->bed.dormno);printf("请输⼊床号:");scanf("%d",&p2->bed.bedno);printf("是否有⼈居住(1/0):");scanf("%d",&p2->bed.isstay);printf("请输⼊学⽣学号:");scanf("%d",&p2->stuno);a[length]=p2->stuno;if(length>1){for(j=1;j<length;j++){if(a[length]==a[j]){printf("该床位号已存在,请重新输⼊:");scanf("%d",&p2->bed.bedno);}}}printf("请输⼊学⽣姓名:");scanf("%s",p2->name);printf("请输⼊学⽣班级:");scanf("%s",p2->stucla);printf("请输⼊学⽣⼊住时间(年⽉)<如2015 5>:");scanf("%d%d",&p2->year,&p2->month);if(p2->year<1000||p2->year>9999||p2->month>12||p2->month<1) {printf("对不起,输⼊错误,请重新输⼊!\n");scanf("%d%d\n",&p2->year,&p2->month);}length++;p1->next=p2;p2->next=NULL;p1=p1->next;printf("第%d个住宿信息创建成功!\n",length);Sleep(300);fflush(stdin);printf("是否继续添加住宿信息?<y/Y>");ch=getchar();} while(ch=='y'||ch=='Y');}void display(){int flag=0,No;p3=head->next;scanf("%d",&No);while(p3!=NULL){if(p3->stuno==No){printf("\n住宿信息如下:");printf("\n宿舍号:%d",p3->bed.dormno);printf("\n床位号:%d",p3->bed.bedno);printf("\n是否有⼈⼊住:%d",p3->bed.isstay);printf("\n学⽣学号:%d",p3->stuno);printf("\n学⽣姓名:%s",p3->name);printf("\n学⽣班级:%s",p3->stucla);printf("\n⼊住时间为:%d年%d⽉\n",p3->year,p3->month); flag=1;}p3=p3->next;}if(!flag)printf("没有找到该学⽣住宿信息!\n");}void disbed(){int flag=0,DormNo;p3=head->next;printf("请输⼊宿舍号:");scanf("%d",&DormNo);while(p3!=NULL){if(p3->bed.dormno==DormNo){printf("\n住宿信息如下:");printf("\n宿舍号:%d",p3->bed.dormno);printf("\n床位号:%d",p3->bed.bedno);printf("\n是否有⼈⼊住:%d",p3->bed.isstay);printf("\n学⽣学号:%d",p3->stuno);printf("\n学⽣姓名:%s",p3->name);printf("\n学⽣班级:%s",p3->stucla);printf("\n⼊住时间为:%d年%d⽉\n",p3->year,p3->month); flag=1;}p3=p3->next;}if(!flag)printf("没有找到该学⽣住宿信息!\n");}void modify(){struct dorminfo *p;int DormNo,BedNo,flag;int Dormno,Bedno,Isstay,Stuno,Year,Month;char Name[20],Stucla[20];if(head==NULL){printf("住宿信息为空,不能修改,按任意键返回...\n");getch();system("cls");return ;}p1=p3=head;printf("请输⼊宿舍号、床位号:");scanf("%d %d",&DormNo,&BedNo);while(p3!=NULL){if(p3->bed.dormno==DormNo&&p3->bed.bedno==BedNo) {printf("已找到要修改的宿舍号、床位号!\n");flag=1;p=p3;}p3=p3->next;}if(flag){printf("请输⼊修改后的宿舍号:");scanf("%d",&Dormno);printf("请输⼊修改后的床号:");scanf("%d",&Bedno);printf("是否有⼈居住(1/0):");scanf("%d",&Isstay);printf("请输⼊修改后的学⽣学号:");scanf("%d",&Stuno);while(p1!=NULL){if(p1->stuno==Stuno){printf("该床位号已存在,请重新输⼊:");scanf("%d",&Stuno);}p1=p1->next;}printf("请输⼊修改后的学⽣姓名:");scanf("%s",Name);printf("请输⼊修改后的学⽣班级:");scanf("%s",Stucla);printf("请输⼊修改后的学⽣⼊住时间(年⽉)<如2015 5>:");scanf("%d%d",&Year,&Month);if(Year<1000||Year>9999||Month>12||Month<1){printf("对不起,输⼊错误,请重新输⼊!\n");scanf("%d%d",&Year,&Month);}p->bed.dormno=Dormno;p->bed.bedno=Bedno;p->bed.isstay=Isstay;p->stuno=Stuno;strcpy(p->name,Name);strcpy(p->stucla,Stucla);p->year=Year;p->month=Month;printf("修改成功,信息如下:\n");printf("-宿舍号--床号--有⽆⼈⼊住--学号--姓名--班级--⼊住时间(年⽉)");printf("\n");printf("%6d%5d%8d%9d%7s%8s%9d%2d\n",p->bed.dormno,p->bed.bedno,p->bed.isstay,p->stuno,p->name,p->stucla,p->year,p->month); }else{printf("没有找到该宿舍号与床号信息,按任意键返回...\n");getch();system("cls");return ;}}void del(){int DormNo,BedNo;p1=head,p2=head->next;printf("请输⼊宿舍号、床位号:");scanf("%d %d",&DormNo,&BedNo);while(p2!=NULL){if(p2->bed.dormno==DormNo&&p2->bed.bedno==BedNo){p1->next=p2->next;free(p2);length--;printf("删除成功!\n");return ;}p2=p2->next;p1=p1->next;}if(p1==NULL)printf("找不到要删除的宿舍号、床位号!\n");}void save(){FILE *fp1;if(head==NULL){printf("\n,没有找到该宿舍号与床号信息,按任意键返回....");getch();system("cls");return ;}if((fp1=fopen("学⽣宿舍管理系统.txt","w"))==NULL){printf("\n信息⽆法保存,按任意键返回....");getch();system("cls");return ;}p1=head->next;printf("正在保存⽂件...\n");Sleep(800);fputs(" 宿舍号床号有⽆⼈⼊住学号姓名班级⼊住时间(年⽉) :\n",fp1);while(p1!=NULL){fprintf(fp1,"%6d%5d%8d%7d%6s%4s%7d%2d\n",p1->bed.dormno,p1->bed.bedno,p1->bed.isstay,p1->stuno,p1->name,p1->stucla,p1->year,p1->month);p1=p1->next;}fclose(fp1);printf("⽂件保存成功!\n");printf("按任意键返回...\n");getch();system("cls");return ;}void read(){FILE *fp2;char ch;if((fp2=fopen("学⽣宿舍管理系统.txt","r"))==NULL){printf("⽂件⽆法打开!\n");exit(0);}printf("正在读⼊⽂件...\n");Sleep(1000);ch=fgetc(fp2);while(!feof(fp2)){putchar(ch);ch=fgetc(fp2);}printf("\n");fclose(fp2);printf("⽂件读⼊成功!\n");}void main(){while(1){processmenu(); system("pause"); system("cls");}}。
C语言——学生宿舍管理系统
#include<>#include<>#include<>入学生信息 ");printf(" \t2.按学号查询 \n");printf(" \t3.按宿舍号查询 ");printf(" \t4.按姓名查询 \n");printf(" \t5.按系别或专业查询 ");printf(" \t6.添加信息 \n");printf(" \t7.修改信息 ");printf(" \t8.保存信息 \n");printf(" \t9.读取信息 ");printf(" \t10.删除信息 \n");printf(" \t0.退出系统 \n");printf("\t*************************************************************\n");printf("------------------------------------------------------------------\n");printf(" \t请选择你想实现的功能:");scanf("%s",&ch);orNo) ;printf("\n姓名:");scanf("%s",&stu[i].stuName);printf("\n学号:");scanf("%d",&stu[i].stuNo);printf("\n性别:");scanf("%s",&stu[i].stuSex);printf("\n系别:");scanf("%s",&stu[i].dept);printf("\n专业:");scanf("%s",&stu[i].major);printf("\n电话:");scanf("%d",&stu[i].tel);i++;}else{printf(" \n\t 人数已满无法继续输入");printf("\n是退出该功能输入(Y/N):");ch=getchar();ch=getchar();}}while(ch!='y'&&ch!='Y');write(stu,num);system("cls");}tuNo){printf("\n宿舍号: %d\n姓名: %s\n学号: %d\n性别: %s\n系别: %s\n专业:%s\n电话号码: %d\n",stu[i].dorNo,stu[i].stuName,stu[i].stuNo,stu[i].stuSex,stu[i].dept,stu[i].major,stu[i].tel);}}}else{printf("\n\t 没有你要查找的学生信息。
宿舍管理系统源代码
#include<stdio.h>#include<stdlib.h>#include<string.h>typedef struct Student{char name[20];char sex[5];int age;char institute[20];char specialty[30]; }Student;typedef struct Room{int roomnum;int roomarea;int totalnum;int stunum;Student stu[10];Room *next; }Room;typedef struct Story{char storynum;Room *room;}Story;/* -------------------------------------------------------------- */Student *StudentCreat(int age,char name[],char institute[],char specialty[],char sex[]){Student *Stu;Stu=(Student *)malloc(sizeof(Student));Stu->age=age;strcpy(Stu->institute,institute); strcpy(Stu->name,name);strcpy(Stu->specialty,specialty); strcpy(Stu->sex,sex);return Stu;}Room *RoomCreat(int room_num,int room_area,int total_num,int stu_num) {Room *R;int i;R=(Room *)malloc(sizeof(Room));if(!R)return NULL;R->roomnum=room_num;R->roomarea=room_area;R->totalnum=total_num;R->stunum=stu_num;R->next=NULL;return R;}Story *StoryCreat(){Story *S;S=(Story *)malloc(sizeof(Story));S->room=RoomCreat(0,0,0,0);return S;}Story *DormCreat(){Story *S,*control;char i;control=(Story *)malloc(26*sizeof(Story)); if(!control)return NULL;for(i='A';i<='Z';i++){S=StoryCreat(); S->storynum=i; control[i-'A']=*S;}return control;}/* -------------------------------------------------------------- */Story *StorySearch(Story *control,char storynum){return control+(storynum-'A');}Room *RoomSearch(Room *R,int room_num){while(R->next!=NULL){ if(R->next->roomnum==room_num)break; else R=R->next;}return R;}Student *StudentSearch(Room *R,char name[]){Student *p;int i;R=R->next; p=R->stu;for(i=0;i<R->stunum;i++){ if(strcmp(p->name,name)==0)return p; else p++;}return NULL;}/* -------------------------------------------------------------- */void RoomInsert(Story *S,Room *R){R->next=S->room->next; S->room->next=R;}void StudentInsert(Room *R,Student *Stu){R=R->next;R->stu[R->stunum]=*Stu;R->stunum++;}void RoomDelete(Room *R){Room *p;R=R->next;p=R;R=R->next;free(p);}void StudentDelete(Room *R,Student *Stu){R=R->next;Student *p; for(p=R->stu;Stu<p+R->stunum-1;Stu++)*Stu=*(Stu+1);R->stunum--;}void RoomRevamp(Room *R){int i,k;R=R->next;printf("1 、房号 2 、面积 3 、可容纳人数 :\n");printf(" 要修改那一项 :\n");scanf("%d",&i); switch(i)case 1:{ printf(" 房号 :"); scanf("%d",&k); R->roomnum=k; break;}case 2:{ printf(" 面积 :"); scanf("%d",&k); R->roomarea=k; break;}case 3:{ printf(" 可容纳人数 :"); scanf("%d",&k); R->totalnum =k;break;}}}void StudentRevamp(Student *Stu){int i,k;char str[30];printf("1 、姓名 2 、性别 3 、学院 4 、专业 5 、年龄 :\n");printf(" 要修改那一项 :\n");scanf("%d",&i); switch(i){case 1:{printf(" 姓名 :");scanf("%s",str); strcpy(Stu->name,str); break;}case 2:{printf(" 性别 :");scanf("%s",str); strcpy(Stu->sex,str);break;}case 3:{printf(" 学院 :");scanf("%s",str); strcpy(Stu->institute,str); break;}case 4:{printf(" 专业 :");scanf("%s",str); strcpy(Stu->specialty,str); break;}case 5:{printf(" 年龄 :");scanf("%d",&k);Stu->age =k;break;}}/* ------------------------------------------- ------------------- */void RoomScan(Room *R){int i;Student*p;R=R->next;printf(" 房号:%d\n",R->room nu m);printf(" 面积:%d\n",R->roomarea);printf(" 可容纳人数 :%d\n",R->totalnum);printf(" 已住入人数 :%d\n",R->stunum);printf(" 成员:");for(i=0;i<R->stunum;i++){p=&(R->stu[i]);printf("%s ",p->name);}putchar('\n');}void StudentScan(Student *Stu){printf(" 姓名 :%s\n",Stu->name);printf(" 年龄 :%d\n",Stu->age);printf(" 性别 :%s\n",Stu->sex);printf("学院 :%s\n",Stu->institute);printf("专业 :%s\n",Stu->specialty);}int main(){int roomnum,roomarea,totalnum,stunum,age;int event;char name[20],institute[20],specialty[30],sex[5];char storynum,judge;Story *control;Story *S;Room *R;Student *Stu;control=DormCreat();do{printf(" **************************************************************\n");*\n");*\n");f*************************************************************宿舍管理系统\n\n\n");printf (" 功能选择菜单 :\n");printf ("1 、宿舍信息录入 2 、学生信息录入 3 、删除某个宿舍 4 、删 除某个学生 \n");printf("5 、宿舍信息浏览 6 、学生信息浏览 7 、宿舍信息修改 8 、学 生信息修改 \n");scanf("%d",&event);、,I • 、、printf("*先录入宿舍信息才能录入学生信息 printf("* 先录入信息才能删除浏览或修改信息 printf("*** **\n"); printf("\n\n\nswitch(event){case 1:{do{printf(" 请输入宿舍房间号,房间面积,可容纳人数,已住入人数 :( 以空格隔开 )\n");fflush(stdin);scanf("%c%d %d%d%d",&storynum,&roomnum,&roomarea,&totalnum,&stunum);S=StorySearch(control,storynum);R=RoomCreat(roomnum,roomarea,totalnum,stunum); RoomInsert(S,R);printf(" 宿舍信息录入成功! \n");fflush(stdin);printf(" 是否继续录入宿舍信息 (Y/N)\n");scanf("%c",&judge);}while(judge=='Y'); break;}case 2:{do{printf(" 请输入该生要入住的宿舍 :\n"); fflush(stdin);scanf("%c%d",&storynum,&roomnum); fflush(stdin);S=StorySearch(control,storynum); R=S->room;R=RoomSearch(R,roomnum);printf(" 请输入该生姓名,性别,学院,专业,年龄 :( 以空格隔开 )\n");scanf("%s%s%s%s",name,sex,institute,specialty); scanf("%d",&age);Stu=StudentCreat(age,name,institute,specialty,sex);StudentInsert(R,Stu);printf(" fflush(stdin); printf("scanf("%c",&judge);}while(judge=='Y');break;break;do { printf(" 请输入要删除的宿舍号码 :\n"); fflush(stdin); scanf("%c%d",&storynum,&roomnum); fflush(stdin); S=StorySearch(control,storynum); R=S->room; R=RoomSearch(R,roomnum); RoomDelete(R); printf(" 宿舍信息删除成功! \n"); fflush(stdin); printf(" 是否继续删除宿舍信息 (Y/N)\n"); scanf("%c",&judge); }while(judge=='Y'); break; break;do{printf(" 请输入要删除学生现住宿舍 :\n"); fflush(stdin); scanf("%c%d",&storynum,&roomnum); fflush(stdin); S=StorySearch(control,storynum);R=S->room;R=RoomSearch(R,roomnum);printf(" 请输入要删除学生的姓名 :\n");scanf("%s",name);Stu=StudentSearch(R,name);StudentDelete(R,Stu);printf(" 学生信息删除成功! \n"); } case 3: {}case 4:{ 学生信息录入成功! \n"); 是否继续录入学生信息 (Y/N)\n");fflush(stdin);printf(" 是否继续删除学生信息(Y/N)\n");scanf("%c",&judge);}while(judge=='Y');break;break;}case 5:{do{printf(" 请输入要浏览的宿舍号码 :\n");fflush(stdin);scanf("%c%d",&storynum,&roomnum);fflush(stdin);S=StorySearch(control,storynum);R=S->room;R=RoomSearch(R,roomnum);RoomScan(R);fflush(stdin);printf(" 是否继续浏览宿舍 (Y/N)\n");scanf("%c",&judge);}while(judge=='Y');break;break;}case 6:{do{printf(" 请输入要浏览学生的宿舍号码:\n");fflush(stdin);scanf("%c%d",&storynum,&roomnum);fflush(stdin);S=StorySearch(control,storynum);R=S->room;R=RoomSearch(R,roomnum);printf(" 请输入要浏览学生的姓名 :\n");scanf("%s",name);Stu=StudentSearch(R,name);StudentScan(Stu);fflush(stdin);printf(" 是否继续浏览学生 (Y/N)\n");scanf("%c",&judge);}while(judge=='Y');break;break;}case 7:{do{printf(" 请输入要修改的宿舍号码 :\n");fflush(stdin);scanf("%c%d",&storynum,&roomnum);fflush(stdin);S=StorySearch(control,storynum);R=S->room;R=RoomSearch(R,roomnum);RoomRevamp(R);printf(" 宿舍信息修改成功! \n");fflush(stdin);printf(" 是否继续修改 (Y/N)\n");scanf("%c",&judge);}while(judge=='Y');break;break;}case 8:{do{printf(" 请输入要修改学生的宿舍号码:\n");fflush(stdin); scanf("%c%d",&storynum,&roomnum);fflush(stdin);S=StorySearch(control,storynum);R=S->room;R=RoomSearch(R,roomnum);printf(" 请输入要修改学生的姓名 :\n");scanf("%s",name);Stu=StudentSearch(R,name);StudentRevamp(Stu);printf(" 学生信息修改成功! \n");fflush(stdin);printf(" 是否继续修改 (Y/N)\n");scanf("%c",&judge);}while(judge=='Y');break;break;}}fflush(stdin);printf(" 是否继续其他操作 (Y/N)\n");scanf("%c",&judge);}while(judge=='Y');system("pause");}欢迎您的下载,资料仅供参考!致力为企业和个人提供合同协议,策划案计划书,学习资料等等打造全网一站式需求。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
源程序代码:#include<stdio.h>#include<string.h>#include<stdlib.h>#define M 100int dirty=0; //用来判断是否已保存操作//定义一个存储学生相关信息的结构体typedef struct{char S_name[31]; //学生姓名char S_class[31]; //学生班级char S_number[16]; //学生学号int D_number; //学生所在寝室的宿舍号char S_address[500]; //学生地址int S_phone[20]; //学生电话号码int Total; //学生总数}Student[M],St;//判断学号是否与表中所存学号重复void S_number_Judge(Student S,int t){int i;for(i=1;i<=(S->Total)-1;i++)while(strcmp(S[i].S_number,S[t].S_number)==0){printf("学号输入失败,该学号已存在,请重新输入学号!\n");printf("请输入学生的学号(15个字符以内):");scanf("%s",S[t].S_number);getchar();i=1;}}//添加学生信息函数void Add(Student S){printf("请输入学生姓名(30个字符以内):");scanf("%s",S[++(S->Total)].S_name);getchar();//获取换行符printf(“请输入学生班级(30个字符以内):”);scanf("%s",S[S->Total].S_class);getchar();printf("请输入学生的学号(15个字符以内):");scanf("%s",S[S->Total].S_number);getchar();S_number_Judge(S,S->Total);//判断输入的学号是否与表中所存在的学号重复printf("请输入宿舍号码:");scanf("%d",&S[S->Total].D_number);getchar();printf("请输入学生地址:");scanf("%s",S[S->Total].S_address);getchar();printf(“请输入学生电话号码:”);scanf("%s",&S[S->Total]. S_phone);getchar();dirty=1;printf("添加成功!\n\n");}//修改学生信息函数void Alter(Student S){int i;int flag=0; //用来判断表中是否存在所要修改的学生的信息char name[20];printf("请输入你要修改学生的姓名:");scanf("%s",name);getchar();for(i=1;i<=S->Total;i++)if(strcmp(S[i].S_name,name)==0)flag=i;if(!flag)printf("你所要修改的学生信息在表中不存在!\n");else{printf("新信息如下:\n");printf("请输入学生姓名(30个字符以内):");scanf("%s",S[flag].S_name);getchar();printf(“请输入学生班级(30个字符以内):”);scanf("%s",S[flag].S_class);getchar();printf("请输入学生的学号(15个字符以内):");scanf("%s",S[flag].S_number);getchar();S_number_Judge(S,flag);printf("请输入宿舍号:");scanf("%d",&S[flag].D_number);getchar();printf("请输入学生地址:");scanf("%s",S[flag].S_address);getchar();printf(“请输入学生电话号码:”);scanf("%s",&S[flag]. S_phone);getchar();dirty=1;printf("修改成功!\n");}putchar('\n');}//删除学生信息void Delete(Student S){int i,j;int flag=0; //用来判断表中是否存在所要删除的学生的信息char name[20];printf("请输入你要删除学生的姓名:");scanf("%s",name);getchar();for(i=1;i<=S->Total;i++)if(strcmp(S[i].S_name,name)==0)flag=i;if(!flag)printf("你所要删除的学生在表中不存在!");else{for(i=flag;i<S->Total;i++){j=i+1;strcpy(S[i].S_name,S[j].S_name);strcpy(S[i].S_number,S[j].S_number);S[i].D_number=S[j].D_number;}(S->Total)--;dirty=1;printf("删除成功!");}printf("\n\n");}//显示所有学生信息函数void Display_All(Student S){int i;printf("全体学生信息如下:\n");printf("学生姓名学生班级学生学号宿舍号学生地址学生电话号码\n");for(i=1;i<=S->Total;i++)printf("%-20s%-20s %-15s%-5d%s-10%s\n",S[i].S_name,S[i].S_class,S[i].S_number,S[i].D_number,S[i].S_add ress,S[i].S_phone);putchar('\n\n');}//排序函数按照寝室号从小到大排序(冒泡法)void Sort_D_number(Student S){int i,j,t;char name[30];char number[15];char address[300];char Cnumber[30];for(i=1;i<=S->Total;i++)for(j=i;j<=S->Total;j++)if(S[i].D_number>S[j].D_number){strcpy(name,S[i].S_name);strcpy(number,S[i].S_number);strcpy(address,S[i].S_address);strcpy(Cnumber,S[i].S_class);t=S[i].D_number;strcpy(S[i].S_name,S[j].S_name);strcpy(S[i].S_number,S[j].S_number);strcpy(S[i].S_address,S[j].S_address);;strcpy(S[i].S_class,S[j].S_class);S[i].D_number=S[j].D_number;strcpy(S[j].S_name,name);strcpy(S[j].S_number,number);strcpy(S[j].S_address,address);strcpy(S[j].S_class,Cnumber);S[j].D_number=t;}}//排序函数按照学号从小到大排序(冒泡法)void Sort_S_number(Student S){int i,j,t;char name[30];char number[15];char address[300];char Cnumber[30];for(i=1;i<=S->Total;i++)for(j=i;j<=S->Total;j++)if(strcmp(S[i].S_number,S[j].S_number)>0){strcpy(name,S[i].S_name);strcpy(number,S[i].S_number);strcpy(address,S[i].S_address);strcpy(Cnumber,S[i].S_class);t=S[i].D_number;strcpy(S[i].S_name,S[j].S_name);strcpy(S[i].S_number,S[j].S_number);strcpy(S[i].S_address,S[j].S_address);; strcpy(S[i].S_class,S[j].S_class);S[i].D_number=S[j].D_number;strcpy(S[j].S_name,name);strcpy(S[j].S_number,number);strcpy(S[j].S_address,address);strcpy(S[j].S_class,Cnumber);S[j].D_number=t;}}//排序函数按照班级号从小到大排序(冒泡法)void Sort_S_class (Student S){int i,j,t;char name[30];char number[15];char address[300];char Cnumber[30];for(i=1;i<=S->Total;i++)for(j=i;j<=S->Total;j++)if(strcmp(S[i].S_class,S[j].S_class)>0){strcpy(name,S[i].S_name);strcpy(number,S[i].S_number);strcpy(address,S[i].S_address);strcpy(Cnumber,S[i].S_class);t=S[i]. D_number;strcpy(S[i].S_name,S[j].S_name);strcpy(S[i].S_number,S[j].S_number);strcpy(S[i].S_address,S[j].S_address);;strcpy(S[i].S_class,S[j].S_class);S[i]. D_number =S[j]. D_number;strcpy(S[j].S_name,name);strcpy(S[j].S_number,number);strcpy(S[j].S_address,address);strcpy(S[j].S_class,Cnumber);S[j]. D_number =t;}}//查询函数以班级为关键字进行查询(顺序查找)void Query_S_class(Student S){int i,j=0;char classnumber[31];printf("请输入你要查找的班级号(30个字符以内):");scanf("%s",classnumber);getchar();printf("所查找学生信息如下:\n");printf("学生姓名学生班级学生学号宿舍号学生地址学生电话号码\n");for(i=1;i<=S->Total;i++)if(strcmp(classnumber,S[i].S_class)==0){printf("%-20s%-20s %-15s%-5d%s-10%s\n",S[i].S_name,S[i].S_class,S[i].S_number,S[i].D_number,S[i].S_address,S[i].S_phone);j=1;}if(!j)printf("\n查找失败,表中不存在该学生的信息!\n\n");}//查询函数以姓名为关键字进行查询(顺序查找)void Query_S_name(Student S){int i,j=0;char name[31];printf("请输入你要查找的学生的姓名(30个字符以内):");scanf("%s",name);getchar();printf("所查找学生信息如下:\n");printf("学生姓名学生班级学生学号宿舍号学生地址学生电话号码\n");for(i=1;i<=S->Total;i++)if(strcmp(name,S[i].S_name)==0){printf("%-20s%-20s %-15s%-5d%s-10%s\n",S[i].S_name,S[i].S_class,S[i].S_number,S[i].D_number,S[i].S_address,S[i].S_phone);j=1;}if(!j)printf("\n查找失败,表中不存在该学生的信息!\n\n");}//查询函数以学号为关键字进行查询(折半查找)void Query_S_number(Student S){int i,j,top,base,mid;char number[15];j=0;base=1;top=S->Total;printf("请输入你要查找学生的学号:");scanf("%s",number);getchar();Sort_S_number(S); //将表中原数据按照学号从小到大排序printf("所查找学生信息如下:\n");printf("学生姓名学生班级学生学号宿舍号学生地址学生电话号码\n");if(strcmp(number,S[1].S_number)>=0&&strcmp(number,S[S->Total].S_number)<=0){while(base<=top){mid=(base+top)/2;if(strcmp(number,S[mid].S_number)==0){printf("%-20s%-20s%-15s%-5d%s-10%s\n",S[i].S_name,S[i].S_class,S[i].S_number,S[i].D_number,S[i].S_address,S[i].S_phone);putchar('\n');j=1;break;}else if(strcmp(number,S[mid].S_number)>0)base=mid+1;elsetop=mid-1;}}if(!j)printf("\n查找失败,表中不存在该学生的信息!\n\n");}//查询函数以寝室号为关键字进行查询(折半查找)void Query_D_number(Student S){int i,j,m,n,base,top,mid;j=0;base=1;top=S->Total;printf("请输入你要查询的寝室号:");scanf("%d",&i);getchar();Sort_D_number(S);//将表中原数据按照寝室号从小到大排序printf("所查找寝室信息如下:\n");printf("学生姓名学生班级学生学号宿舍号学生地址学生电话号码\n");if(i>=S[1].D_number&&i<=S[S->Total].D_number){while(base<=top){mid=(base+top)/2;if(i==S[mid].D_number){m=mid;n=mid-1;while(S[m].D_number==i){printf("%-20s%-20s %-15s%-5d%s-10%s\n",S[m].S_name,S[i].S_class,S[m].S_number,S[m].D_number,S[i].S_address,S[i].S_phone);m++;if(m>S->Total)break;}if(n>0){while(S[n].D_number==i){printf("%-20s%-15s%-5d\n",S[n].S_name,S[n].S_number,S[n].D_number);n--;if(n<1)break;}}j=1;putchar('\n');break;}else if(i>S[mid].D_number)base=mid+1;elsetop=mid-1;}}if(!j)printf("\n查找失败,表中不存在该寝室的信息!\n\n"); }//存储函数void Save(Student S){St Std;int i;int flag1=0,flag2=0; //判断存储是否成功FILE *fp;if((fp=fopen("Dorm_Manage","w"))==NULL){printf("打开文件失败!\n\n");flag1=1;exit(0); //结束程序}for(i=1;i<=S->Total;i++)if(fwrite(&S[i],sizeof(Std),1,fp)!=1){printf("数据写入错误\n\n");flag2=1;exit(0);}if(!flag1&&!flag2){printf("数据存储成功!\n\n");dirty=0;}fclose(fp);}//加载记录函数void Load(Student S){St Std;FILE *fp;if((fp=fopen("Dorm_Manage","r"))==NULL){printf("打开文件失败!\n\n");exit(0);}while(!feof(fp))fread(&S[++(S->Total)],sizeof(Std),1,fp);fclose(fp);printf("加载数据成功!\n\n");(S->Total)--; //由于读取问题,表中个数要减去}//退出程序时判断是否保存函数void Judge_Save(int i,Student S){char ch;if(i){printf("表中数据已改变,是否保存后再退出(Y/N)?:");ch=getchar();getchar();while(ch!='n'&&ch!='N'&&ch!='y'&&ch!='Y'){printf("请输入N(n)或者Y(y):");ch=getchar();getchar();}if(ch=='y'||ch=='Y')Save(S);}}//菜单void Menu(){//菜单printf(" 学生管理\n\n");printf("*************************************菜单*************************************\n");printf("1.添加学生信息 | 8.按照班级号从小到大排序\n”);printf("2.修改学生信息 | 9.按照寝室号从小到大排序\n");printf("3.删除学生信息 | 10.按照学号从小到大排序\n");printf("4.以姓名查询学生信息 | 11.显示所有学生的相关信息\n");printf("5.以学号查询学生信息 | 12.保存操作\n");printf("6.以寝室号查询该寝室中的全部学生信息 | 13.加载记录\n");printf(“7.以班级号查询该班级中的全部学生信息 | 14.退出程序\n");printf("******************************************************************************\n"); }void main(){int i;Student S;S->Total=0;do{Menu();printf("请选择所要实现的功能(请输入1~14中的任意一个数字):");scanf("%d",&i);getchar(); //获取换行符putchar('\n');switch(i){case 1:Add(S);break;case 2:Alter(S);break;case 3:Delete(S);break;case 4:Query_S_name(S);break;case 5:Query_S_number(S);break;case 6:Query_D_number(S);break;case 7: Query_S_class (S);break;case 8: Sort_S_class (S);printf("排序完成!\n\n");break;case 9:Sort_D_number(S);printf("排序完成!\n\n");break;case 10:Sort_S_number(S);printf("排序完成!\n\n");break;case 11:Display_All(S);break;case 12:Save(S);break;case 13:Load(S);break;case 14:Judge_Save(dirty,S);exit(0);break;default:printf("选择错误:请在选项到之间选择!\n\n");break;}}while(i!=14);}。