内容发布更新时间 : 2024/12/26 14:38:22星期一 下面是文章的全部内容请认真阅读。
sprintf(Buf[i],\
Rooms:%d\ } count=huodecaidan(Buf,i-1); for(i=0,pRST_temp=(*pRST);i
; Buf_Clear(); Buf_Fill_Tree(pRST_temp); Display();/*缓冲区中的信息*/ getch(); return 0; }
#define GCO_TITLES 2 #define TOP 10
int tongjijiemian(Pfangjianzhonglei * pRST) { char * szTitles[]={ \ \ \ Pfangjianzhonglei pRST2; int (*comp[GCO_TITLES])(void *,void *)={jiyushijian,jiyujiage};
int count; count=huodecaidan(szTitles,GCO_TITLES); pRST2=(*pRST); Buf_Clear(); while(pRST2){ Buf_Fill_Tree(pRST2); pRST2=pRST2->next; } Collect(comp[count],TOP); Display(); return 0; }
/*通过从硬盘读入来创建一个链表*/ int yindaozairu(Pfangjianzhonglei * pRST) { char * error=\ int i,j;
36
Pfangjianzhonglei pRST_temp,pRST_temp2; Pfangjian pRF,pRF2; Pkehu pC,pC2; FILE * fTree,* fRoom,* fCustom; fTree=fopen(\ fRoom=fopen(\ fCustom=fopen(\ if(!fTree||!fRoom||!fCustom){ printf(error); exit(0); }
(*pRST)=(Pfangjianzhonglei)malloc(sizeof(fangjianzhonglei));pRST_temp=(*pRST); while(1){ if(!huodekefangzhonglei(fTree,pRST_temp)) break; pRST_temp->first=(Pfangjian)malloc(sizeof(fangjian)); for(pRF=pRST_temp->first,i=pRST_temp->shuliang;i;i--){ huodekefang(fRoom,pRF); pRF->Record=(Pkehu)malloc(sizeof(kehu)); for(pC=pRF->Record,j=pRF->times;j;j--){ huodekehu(fCustom,pC); pC->next=(Pkehu)malloc(sizeof(kehu)); pC2=pC; pC=pC->next; }/*for(j*/ pC2->next=NULL; free(pC); pRF2=pRF; pRF->next=(Pfangjian)malloc(sizeof(fangjian)); pRF=pRF->next; }/*for(i*/ pRF2->next=NULL; free(pRF);/*free the last one*/ pRST_temp2=pRST_temp; pRST_temp->next=(Pfangjianzhonglei)malloc(sizeof(fangjianzhonglei));
pRST_temp=pRST_temp->next;
}/*while(!feof*/ pRST_temp2->next=NULL;
free(pRST_temp); fclose(fTree); fclose(fRoom); fclose(fCustom);
37
return 0; }
/*将当前链表保存到磁盘*/ int yindaobaocun(Pfangjianzhonglei * pRST) { char * error=\ int i,j; Pfangjianzhonglei pRST_temp; Pfangjian pRF; Pkehu pC; FILE * fTree,* fRoom,* fCustom; fTree=fopen(\ fRoom=fopen(\ fCustom=fopen(\ if(!fTree||!fRoom||!fCustom){ printf(error); exit(0); } pRST_temp=(*pRST); while(pRST_temp){ xierukefang(fTree,pRST_temp); for(pRF=pRST_temp->first,i=pRST_temp->shuliang;i;i--){ xierukefangxinxi(fRoom,pRF); for(pC=pRF->Record,j=pRF->times;j;j--){ xierukehuxinxi(fCustom,pC); pC=pC->next; }/*for(j*/ pRF=pRF->next; }/*for(i*/ pRST_temp=pRST_temp->next; }/*while(pRST_temp*/ fclose(fTree); fclose(fRoom); fclose(fCustom); return 0; } /*退出*/
int yindaotuichu(Pfangjianzhonglei * pRST) { exit(0); return 0; }
/*功能向导,function(int)是之前菜单中选中的功能,pRST是指向主链表头指针的指针*/
38
int xiangdaohejiemian(int function,Pfangjianzhonglei * pRST) { /*功能函数,用于在显示区域显示相关信息*/ int (* fun[])(Pfangjianzhonglei *)={ yindaochuangjian,charujiemian,xiugaijiemian,shanchujiemian,
suousuojiemian,yindaoshuru,tongjijiemian,yindaozairu,
fun[function](pRST); return 0;
yindaobaocun,yindaotuichu};
39