資源簡介
1.具有建立數據文件(客房信息文件、住客信息文件)功能;
2.具有數據輸入功能;
3.具有數據修改功能;
4.具有數據刪除功能;
5.能查詢(查找)一些基本信息(如按房號查詢、按姓名查詢、空余客房查詢等);
6.具有多種統計功能(要求有一定的實用性)
(如某客房當前有那些空床、某住客應付多少費用、某天住店總人數和總收入等)
7.能具有排序功能(比如在查詢所有的客房信息時,能根據房間價格進行排序,方便客人挑選房間等等)

代碼片段和文件信息
#include
#include
#include
#include
#include?
struct?Room?;
struct?Customer?;
typedef?struct?Room?*?Proom;
typedef?struct?Customer?*?Pcustomer;
struct?Room??
{
int?RoomNumber;//房號
int?RoomType;//房型
int?Price;//單價(每床)
int?Number;?//已住人數???
Proom?next;
};
struct?Customer??
{
char?name[10]ID[19];?//顧客姓名,顧客身份證號
char?sex[5];//性別
int??age;//年齡
int??state;//房型
int??room_number;//房號
int??check_in_date;//入住日期
int??departure_date?;//離店日期
Pcustomer?next;
};
Proom?head_room?=?NULL;
Pcustomer?head_customer?=?NULL;
Proom?r_room?=?NULL; //房間鏈表尾指針
Pcustomer?r_customer?=?NULL;//顧客鏈表尾指針
Proom?update_room_add(int?room_num);
bool?read_room() //讀取room文件來創建鏈表
{
FILE?*filep;
????if((filep?=?fopen(“d://Room.txt““a+“))?==?NULL)
{
printf(“read?file?open?error!“);
getch();
????????return?0;
}
Proom?temp_node?=?NULL;
temp_node?=?(Proom)malloc(sizeof(struct?Room));
temp_node->next?=?NULL;
head_room?=?r_room?=?temp_node;
while(true)
{
if(feof(filep)||fread(temp_nodesizeof(struct?Room)1filep)!=1)
{
free(temp_node);
if?(temp_node?==?head_room)
head_room?=?r_room?=?NULL;
else
r_room->next?=?NULL;
break;
}
r_room->next?=?temp_node;
r_room?=?r_room->next;
temp_node?=?(Proom)malloc(sizeof(struct?Room));
temp_node->next?=?NULL;
}
return?1;
}
bool?write_room()?//保存room鏈表(即房間信息)到room文件
{
FILE?*filep;
????if((filep?=?fopen(“d://Room.txt““w+“))?==?NULL)
{
printf(“read?file?open?error!“);
getch();
????????return?0;
}
Proom?temp_node?=?head_room;
while(?temp_node?!=?NULL?)
{
fwrite(temp_nodesizeof(struct?Room)1filep);
temp_node?=?temp_node->next;
}
fclose(filep);
return?1;
}
bool?read_customer()//讀取customer文件來創建customer鏈表
{
FILE?*fileq;
if((fileq?=?fopen(“d://Customer.txt““a+“))?==?NULL)
{
printf(“read?file?open?error!“);?
getch();
return?0;
????}
Pcustomer?temp_node?=?(Pcustomer)malloc(sizeof(struct?Customer));
head_customer?=?r_customer?=?temp_node;
while(true)
{
if(feof(fileq)||fread(temp_nodesizeof(struct?Customer)1fileq)!=1)
{
free(temp_node);
if?(temp_node?==?head_customer)
head_customer?=?r_customer?=?NULL;
else
r_customer->next?=?NULL;
break;
}
r_customer->next?=?temp_node;
r_customer?=?r_customer->next;
temp_node?=?(Pcustomer)malloc(sizeof(struct?Customer));
temp_node->next?=?NULL;
}
fclose(fileq);
return?1;
}
bool?write_customer()//保存customer鏈表信息到customer文件
{
FILE?*filep;
????if((filep?=?fopen(“d://Customer.txt““w+“))?==?NULL)
{
printf(“read?file?open?error!“);
getch();
????????return?0;
}
Pcustomer?temp_node?=?head_customer;
while(?temp_node?!=?NULL?)
{
fwrite(temp_nodesizeof(struct?Customer)1filep);
temp_node?=?temp_node->next;
}
fclose(filep);
return?1;
}
int?insert_post_link_room?()?//插入房間
{
Proom?temp_node?=?(Proo
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2012-09-12?11:22??簡易客房管理系統\
?????文件????????4472??2012-09-07?18:15??簡易客房管理系統\11.dsp
?????文件?????????552??2012-09-07?18:14??簡易客房管理系統\11.dsw
?????文件???????50176??2012-09-09?20:48??簡易客房管理系統\11.ncb
?????文件???????53760??2012-09-09?20:48??簡易客房管理系統\11.opt
?????文件?????????961??2012-09-09?20:48??簡易客房管理系統\11.plg
?????文件???????????0??2012-09-07?17:57??簡易客房管理系統\Customer.txt
?????目錄???????????0??2012-09-12?11:23??簡易客房管理系統\Debug\
?????文件??????209006??2012-09-09?20:48??簡易客房管理系統\Debug\11.exe
?????文件??????273476??2012-09-09?20:48??簡易客房管理系統\Debug\11.ilk
?????文件?????3561200??2012-09-09?19:21??簡易客房管理系統\Debug\11.pch
?????文件??????533504??2012-09-09?19:40??簡易客房管理系統\Debug\11.pdb
?????文件??????140288??2012-09-09?20:48??簡易客房管理系統\Debug\vc60.idb
?????文件???????77824??2012-09-09?19:40??簡易客房管理系統\Debug\vc60.pdb
?????文件???????52744??2012-09-09?20:48??簡易客房管理系統\Debug\簡易客房管理系統.obj
?????文件???????????0??2012-09-07?17:57??簡易客房管理系統\Room.txt
?????文件???????15960??2012-09-09?19:40??簡易客房管理系統\簡易客房管理系統.cpp
- 上一篇:四級數據庫工程師 完美集錦
- 下一篇:API 網關KONGA安裝手冊
評論
共有 條評論