资源简介
学生宿舍管理系统VC6.0,数据结构课程设计

代码片段和文件信息
#include
#include
#include
#include
#include
typedef struct student//学生信息
{
char name[20];
int studentnum;
int roomnum;
}student;
typedef struct//顺序表储存结构
{
student *elem;
int length;
}stulist;
struct node//哈希表储存结构
{
student info;
node *next;
};
void SelectSortid(stulist stu)
{
int k;
for(int i=0;i {
k=i;
for(int j=i+1;j {
if(stu.elem[j].studentnum if(i!=k)
{
student t;
t=stu.elem[i];
stu.elem[i]=stu.elem[k];
stu.elem[k]=t;
}
}
}
}
void SelectSortroom ( stulist stu) //按房间号选择排序
{
int ijk;
for ( i = 1; i < stu.length; ++i ) // 选择第i个小的记录,并交换到位
{
k = i;
for ( j = i+1; j <=stu.length; ++j ) // 在 L.r[i..length] 中选择 id 最小的记录
if ( stu.elem[j].roomnum if ( i != k ) // 与第 i 个记录交换
{
student t;
t = stu.elem[i];
stu.elem[i] = stu.elem[k];
stu.elem[k] = t;
}
}
}
void inint(stulist& stu)
{
cout<<“请输入学生数目:“;cin>>stu.length;
for(int i=1;i<=stu.length;i++)
{
cout<<“请输入第“< cout<<“姓名:“; cin>>stu.elem[i].name;
cout<<“学号:“; cin>>stu.elem[i].studentnum;
cout<<“房间号:“; cin>>stu.elem[i].roomnum;
}
SelectSortid( stu );
}
int Idcheck(stulist stuint num) //按学号查找(若找到则返回位置,否则返回0)(折半查找)
{
SelectSortid ( stu);
int low=1high=stu.length;
while(low<=high)
{
int mid=(low+high)/2;
if(num==stu.elem[mid].studentnum)
return mid;
else if(num high=mid-1;
else
low=mid+1;
}
return 0;
}
int Roomcheck(stulist stuint roomnum) //按房间号查找
{
int low=1high=stu.length;
while(low<=high)
{
int mid=(low+high)/2;
if(roomnum==stu.elem[mid].roomnum)
return mid;
else if(roomnum high=mid-1;
else
low=mid+1;
}
return 0;
}
void CreathHash(stulist stunode num[27]) //建哈希表(链地址法解决冲突)
{
for(int i=1;i<=26;i++)
num[i].next=NULL;
for(i=1;i<=stu.length;i++)
{
int a=stu.elem[i].name[0]-96;
node *p=(node *)malloc(sizeof(node));
strcpy(p->info.namestu.elem[i].name);
p->info.studentnum=stu.elem[i].studentnum;
p->info.roomnum=stu.elem[i].roomnum;
p->next=num[a].next;
num[a].next=p;
}
}
void Namefind(stulist stunode num[27]char na[20]) //按姓名查找
{
CreathHash(stunum);
for(int i=1;i<=26;i++)
{
node *p=num[i].next;
while(p!=NULL)
{
if(strcmp(p->info.namena)==0)
{
cout<<“该用户的信息为:“< cout<<“姓名:“;
cout<info.name< cout<<“学号:“;
cout<info.studentnum< cout<<“房间号:“;
cout<info.roomnum< return;
}
else
p=p->next;
}
}
cout<<“没有该学生!“< }
void Deleinfo(stulist stu) //删除信息
{
cout<<“请输入您要删除的学生的房间号:“;
int room;cin>>room;
if(!Roomcheck(sturoom))
cout<<“没有该学生!“< e
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 5700 2011-06-19 12:48 学生宿舍C++\学生宿舍.cpp
文件 3427 2011-06-21 18:50 学生宿舍C++\学生宿舍.dsp
文件 524 2011-06-21 18:56 学生宿舍C++\学生宿舍.dsw
文件 41984 2011-06-21 18:56 学生宿舍C++\学生宿舍.ncb
文件 48640 2011-06-21 18:56 学生宿舍C++\学生宿舍.opt
文件 756 2011-06-21 18:50 学生宿舍C++\学生宿舍.plg
目录 0 2012-08-05 11:02 学生宿舍C++\
- 上一篇:算术编码纯C语言实现
- 下一篇:OpenCv背景差分228299
相关资源
- C语言课程设计
- c语言电子商务系统
- 宠物管理系统课程设计(源码+数据库
- c语言课程设计:客房登记系统源码
- 8位竞赛抢答器的课程设计报告.docx
- VC++MFC课程设计的学生成绩管理系统
- C++实现21点游戏
- c++课程设计学生管理系统浙工大源码
- 课程设计: MFC 学生信息管理系统
- dsp课程设计——语音加密.zip
- 广东工业大学数据结构课程设计航空
- 数据结构课程设计扑克牌排序
- c++课程设计宾馆客房管理系统
- c语言课程设计-职工信息管理系统-单
- 飞机票订购系统C语言课程设计报告全
- c++ 课程设计_中国象棋
- 编译原理课程设计-C语言子集编译器
- 操作系统课程设计(银行家算法)附
- 用c写的航空订票系统 航班信息改变
- 信息论课程设计——LZW编码
- 人员管理系统 c语言源码 课程设计专
- MFC课程设计学生管理系统
- vc++课程设计 让计算机来猜测用户“暗
- 职工工作量统计系统.rar
- 扫雷游戏.cpp C++ 课程设计
- C语言数据结构课程设计之统计C程序单
- 职工信息管理系统C 链表
- C++课程设计 扑克牌游戏内含2程序
- 学生成绩管理系统 (C语言版)课程设
- 软件工程课程设计--自动排课排课系统
评论
共有 条评论