急求宿舍管理软件 C语言程序!!!!!

来源:百度知道 编辑:UC知道 时间:2024/06/22 07:57:54
4.宿舍管理查询软件
1)任务:为宿舍管理人员编写一个宿舍管理查询软件, 程序设计要求:
A.采用交互工作方式
B.建立数据文件,数据文件按关键字(姓名、学号、房号)进行排序(冒泡、选择、插入排序等任选一种)
2)查询菜单: (用二分查找实现以下操作)
A.按姓名查询
B.按学号查询
C.按房号查询
3)打印任一查询结果(可以连续操作)

#include <stdio.h>
#define NULL 0
#define TYPE struct student
#define LEN sizeof(struct student)

typedef struct student{
float num;
int room_num;
char name;
struct student *next;
};
struct room{
int room_number;
int count;
}room[4]={{101,0},{102,0},{201,0},{201,0}};
/* 创建一个含 n 个节点的链表 */

TYPE * creatlink(int n)
{ int i;
TYPE *head,*pf,*pb;
head=(TYPE*)malloc(sizeof(TYPE));
head->next=NULL;
pf=head;
pb=head;
for(i=0;i<n;i++)
{
pf=(TYPE*)malloc(sizeof(TYPE));
pf->next=NULL;
printf("请输入学生的相关信息:\n");
printf("学号:"); scanf("%d,",&pf->num);
printf("姓名:"); scanf("%s,",&pf->name);
printf("房间号:"); scanf("%s,",&pf->room_num);
pf->room_num=(room[i/8].room_number);