C语言课程设计宾馆住宿系统

for(i=0;i

return 0; }

int Get_Info(char * * szTitles,char * * buffer,int num)

{ int i; for(i=0;i

/*根据人数排序*/ int jiyushijian(void * a,void * b) { if(((Pfangjian)a)->times>((Pfangjian)b)->times)

return 1; else return -1; } /*根据价格排序*/ int jiyujiage(void * a,void * b) { if(((Pfangjian)a)->jiage>((Pfangjian)b)->jiage)

return 1; else return -1; }

int Collect(int (* Comp)(void *,void *),int num)

{ Qsort(Buf_Room.Buffer,0,Buf_Room.Bufsize-1,Comp); if(Buf_Room.Bufsize>num) Buf_Room.Bufsize=num; return 0; }

int huodecaidan(char * * szTitles,int num)/*菜单循环*/{ int i,count; printf(\

31

while(1){ printf(\ for(i=1;i<=num;i++) printf(\ scanf(\ if(count<0||count>num){ printf(\ continue; } else{ clrscr(); return count-1; } } }

void swap(void * * array,int a,int b){ void * temp; temp=(void *)array[a]; array[a]=array[b]; array[b]=temp; }

void Qsort(void * * array,int low,int high,int (*Comp)(void * ,void * )){

int middle,i; if(low>=high) return; middle=(low+high)/2; swap(array,middle,low); for(middle=low,i=low+1;i<=high;i++){

if(Comp(array[low],array[i])>0) swap(array,++middle,i);

} swap(array,middle,low); Qsort(array,low,middle-1,Comp); Qsort(array,middle+1,high,Comp); } #define MENU 10 void init(void) { Buf_Room.Buffer=(Pfangjian *)malloc(sizeof(fangjian *)*MAX_ROOM); Buf_Room.Bufsize=0; }

32

int main() { int count; char * szMenu[MENU+1]={ \ \ \ \ \ \ \the list\ \the list\ \the list\ \the list\ \ };/*Fill it*/ Pfangjianzhonglei pRST_Head=NULL; init(); while(1){/*主循环*/ count=huodecaidan(szMenu,MENU); xiangdaohejiemian(count,&pRST_Head); } return 0; } #define TITLES 5 #define MAX_TYPES 8 /*新建一个链表*/ #define GC_TITLES 3

int yindaochuangjian(Pfangjianzhonglei * pRST) { char * szTitles=\ char * szRoom={\ int i,num_rooms,num; Pfangjianzhonglei pRST_temp,pRST_temp2; (*pRST)=(Pfangjianzhonglei)malloc(sizeof(fangjianzhonglei)); printf(szTitles); scanf(\ for(i=1,pRST_temp=(*pRST);i<=num;i++){ printf(\ printf(\ scanf(\

33

pRST_temp->shuliang=num_rooms; pRST_temp->zhonglei=i+'0'; huodenkefang(pRST_temp,num_rooms);

pRST_temp->next=(Pfangjianzhonglei)malloc(sizeof(fangjianzhonglei));

pRST_temp2=pRST_temp; pRST_temp=pRST_temp->next;

} pRST_temp2->next=NULL; return 0; } #define GI_TITLES 3

int charujiemian(Pfangjianzhonglei * pRST)

{ char * szInsert[]={ \

\ \ \ int (*Insert_Fun[])(Pfangjianzhonglei)={

tianjiazhonglei,tianjiakefang,tianjiakehu};

int count; count=huodecaidan(szInsert,GI_TITLES);

Insert_Fun[count]((*pRST)); return 0; }

#define GM_TITLES 2 int xiugaijiemian(Pfangjianzhonglei * pRST)

{ char * szDelete[]={ \

\ \ int (*Modify_Fun[])(Pfangjianzhonglei )={

xiugaikefangzhonglei,xiugaikehu};

int count; count=huodecaidan(szDelete,GM_TITLES);

Modify_Fun[count]((*pRST)); return 0; }

#define GD_TITLES 3

int shanchujiemian(Pfangjianzhonglei * pRST)

{

34

char * szDelete[]={ \ \ \ \ int (*Delete_Fun[])(Pfangjianzhonglei *)={ shanchuzhonglei,shanchukefang,shanchukehu}; int count; count=huodecaidan(szDelete,GD_TITLES); Delete_Fun[count](pRST); return 0; } #define GS_TITLES 3

int suousuojiemian(Pfangjianzhonglei * pRST) { char * szTitles[]={ \ \ \ \ int (* fun[GS_TITLES])(Pfangjianzhonglei )={sousuokefangzhonglei,sousuokefangxinxi,sousuokehu};

int count; count=huodecaidan(szTitles,GS_TITLES); fun[count]((*pRST)); return 0; }

#define MAX_SHOW 100 int yindaoshuru(Pfangjianzhonglei * pRST) { Pfangjianzhonglei pRST_temp; int count,i; char ** Buf; Buf=(char **)malloc(sizeof(char*)*MAX_SHOW); Buf[0]=(char *)malloc(sizeof(char)*BUFSIZE); sprintf(Buf[0],\ for(pRST_temp=(*pRST),i=1;pRST_temp; i++,pRST_temp=pRST_temp->next){ Buf[i]=(char *)malloc(sizeof(char)*BUFSIZE);

35

联系客服:779662525#qq.com(#替换为@) 苏ICP备20003344号-4