| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2904 人关注过本帖
标题:C语言实习题目,自己不行了..搞不定回不了家了....
只看楼主 加入收藏
mzjllh
Rank: 2
来 自:江苏扬州
等 级:论坛游民
帖 子:76
专家分:41
注 册:2007-2-8
收藏
得分:0 

void statistic() /*统计*/
{
char choice='x';
char roomstatus[10];
unsigned done=0;
unsigned roomcnt=0;
unsigned emptycnt=0;
unsigned bookedcnt=0;
unsigned checkedincnt=0;
unsigned customercnt=0;
struct Rooms *ROOMCUSOR=NULL;
struct Roomp *REMPTYS=NULL;
struct Roomp *RBOOKEDS=NULL;
struct Roomp *RCHECKEDINS=NULL;
struct Roomp *RPCUSOR=NULL;
struct Customers *CUSTOMERHEAD=NULL;
struct Customers *CUSTOMERCUSOR=NULL;
struct Customers *CBOOKEDS=NULL;
struct Customers *CCHECKEDINS=NULL;
struct Customers *ALLCUSTOMERS=NULL;
struct Customers *CPCUSOR=NULL;
struct Rooms *HEAD=ROOM;
struct Rooms *CUSOR=HEAD;
struct Roomp *REMPTYSCUSOR=NULL;
struct Roomp *RBOOKEDSCUSOR=NULL;
struct Roomp *RCHECKEDINSCUSOR=NULL;
struct Customers *CBOOKEDSCUSOR=NULL;
struct Customers *CCHECKEDINSCUSOR=NULL;
struct Customers *ALLCUSTOMERSCUSOR=NULL;
cls();
printf("\t\t =============================================\n");
printf("\t\t * 统 计 选 单 *\n");
printf("\t\t *===========================================*\n");
printf("\t\t * 1.客房概况 6.顾客概况 *\n");
printf("\t\t *                     *\n");
printf("\t\t * 2.所有客房 7.所有顾客 *\n");
printf("\t\t *                     *\n");
printf("\t\t * 3.空闲客房 8.订房顾客 *\n");
printf("\t\t *                     *\n");
printf("\t\t * 4.预订客房 9.入住顾客 *\n");
printf("\t\t *                     *\n");
printf("\t\t * 5.入住客房 0.退出统计 *\n");
printf("\t\t =============================================\n");
while(1)
{
printf("\n请选择统计项目:");
choice=getchar();
flushstdin();
switch(choice)
{
case '1':
{
printf("\n正在统计...\n");
if(!done)
{
CUSOR=ROOM;
while(CUSOR!=NULL)
{
if(CUSOR->theroom.Sing==EMPTY)
{
if(REMPTYS==NULL)
{
REMPTYSCUSOR=malloc(sizeof(struct Roomp));
REMPTYSCUSOR->theroom=&(CUSOR->theroom);
REMPTYS=REMPTYSCUSOR;
REMPTYS->before=NULL;
REMPTYS->next=NULL;
}
else
{
REMPTYSCUSOR->next=malloc(sizeof(struct Roomp));
REMPTYSCUSOR->next->before=REMPTYSCUSOR;
REMPTYSCUSOR=REMPTYSCUSOR->next;
REMPTYSCUSOR->theroom=&CUSOR->theroom;
REMPTYSCUSOR->next=NULL;
}
emptycnt++;
roomcnt++;
}
if(CUSOR->theroom.Sing==BOOKED)
{
if(RBOOKEDS==NULL)
{
RBOOKEDSCUSOR=malloc(sizeof(struct Roomp));
RBOOKEDSCUSOR->theroom=&(CUSOR->theroom);
RBOOKEDS=RBOOKEDSCUSOR;
RBOOKEDS->before=NULL;
RBOOKEDS->next=NULL;
}
else
{
RBOOKEDSCUSOR->next=malloc(sizeof(struct Roomp));
RBOOKEDSCUSOR->next->before=RBOOKEDSCUSOR;
RBOOKEDSCUSOR=RBOOKEDSCUSOR->next;
RBOOKEDSCUSOR->theroom=&(CUSOR->theroom);
RBOOKEDSCUSOR->next=NULL;
}
if(CBOOKEDS==NULL)
{
CBOOKEDSCUSOR=malloc(sizeof(struct Customers));
CBOOKEDSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
CBOOKEDS=CBOOKEDSCUSOR;
CBOOKEDS->before=NULL;
CBOOKEDS->next=NULL;
}
else
{
CBOOKEDSCUSOR->next=malloc(sizeof(struct Customers));
CBOOKEDSCUSOR->next->before=CBOOKEDSCUSOR;
CBOOKEDSCUSOR=CBOOKEDSCUSOR->next;
CBOOKEDSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
CBOOKEDSCUSOR->next=NULL;
}
if(ALLCUSTOMERS==NULL)
{
ALLCUSTOMERSCUSOR=malloc(sizeof(struct Customers));
ALLCUSTOMERSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
ALLCUSTOMERS=ALLCUSTOMERSCUSOR;
ALLCUSTOMERS->before=NULL;
ALLCUSTOMERS->next=NULL;
}
else
{
ALLCUSTOMERSCUSOR->next=malloc(sizeof(struct Customers));
ALLCUSTOMERSCUSOR->next->before=ALLCUSTOMERSCUSOR;
ALLCUSTOMERSCUSOR=ALLCUSTOMERSCUSOR->next;
ALLCUSTOMERSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
ALLCUSTOMERSCUSOR->next=NULL;
}
bookedcnt++;
roomcnt++;
customercnt++;
}
if(CUSOR->theroom.Sing==CHECKEDIN)
{
if(RCHECKEDINS==NULL)
{
RCHECKEDINSCUSOR=malloc(sizeof(struct Roomp));
RCHECKEDINSCUSOR->theroom=&CUSOR->theroom;
RCHECKEDINS=RCHECKEDINSCUSOR;
RCHECKEDINS->before=NULL;
RCHECKEDINS->next=NULL;
}
else
{
RCHECKEDINSCUSOR->next=malloc(sizeof(struct Roomp));
RCHECKEDINSCUSOR->next->before=RCHECKEDINSCUSOR;
RCHECKEDINSCUSOR=RCHECKEDINSCUSOR->next;
RCHECKEDINSCUSOR->theroom=&CUSOR->theroom;
RCHECKEDINSCUSOR->next=NULL;
}
if(CCHECKEDINS==NULL)
{
CCHECKEDINSCUSOR=malloc(sizeof(struct Customers));
CCHECKEDINSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
CCHECKEDINS=CCHECKEDINSCUSOR;
CCHECKEDINS->before=NULL;
CCHECKEDINS->next=NULL;
}
else
{
CCHECKEDINSCUSOR->next=malloc(sizeof(struct Customers));
CCHECKEDINSCUSOR->next->before=CCHECKEDINSCUSOR;
CCHECKEDINSCUSOR=CCHECKEDINSCUSOR->next;
CCHECKEDINSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
CCHECKEDINSCUSOR->next=NULL;
}
if(ALLCUSTOMERS==NULL)
{
ALLCUSTOMERSCUSOR=malloc(sizeof(struct Customers));
ALLCUSTOMERSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
ALLCUSTOMERS=ALLCUSTOMERSCUSOR;
ALLCUSTOMERS->before=NULL;
ALLCUSTOMERS->next=NULL;
}
else
{
ALLCUSTOMERSCUSOR->next=malloc(sizeof(struct Customers));
ALLCUSTOMERSCUSOR->next->before=ALLCUSTOMERSCUSOR;
ALLCUSTOMERSCUSOR=ALLCUSTOMERSCUSOR->next;
ALLCUSTOMERSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
ALLCUSTOMERSCUSOR->next=NULL;
}
checkedincnt++;
roomcnt++;
customercnt++;
}
CUSOR=CUSOR->next;
}
done=1;
}
printf("\t\t\t ======客房概况统计======\n");
printf("\t\t =============================================\n");
printf("\t\t 总 数 空 闲 预 订 入 住 \n");
printf("\t\t =============================================\n");
printf("\t\t %3u %3u %3u %3u \n",roomcnt,emptycnt,bookedcnt,checkedincnt);
printf("\t\t =============================================\n");
break;
}
case '2':
{
printf("\n正在统计...\n");
if(!done)
{
CUSOR=ROOM;
while(CUSOR!=NULL)
{
if(CUSOR->theroom.Sing==EMPTY)
{
if(REMPTYS==NULL)
{
REMPTYSCUSOR=malloc(sizeof(struct Roomp));
REMPTYSCUSOR->theroom=&(CUSOR->theroom);
REMPTYS=REMPTYSCUSOR;
REMPTYS->before=NULL;
REMPTYS->next=NULL;
}
else
{
REMPTYSCUSOR->next=malloc(sizeof(struct Roomp));
REMPTYSCUSOR->next->before=REMPTYSCUSOR;
REMPTYSCUSOR=REMPTYSCUSOR->next;
REMPTYSCUSOR->theroom=&CUSOR->theroom;
REMPTYSCUSOR->next=NULL;
}
emptycnt++;
roomcnt++;
}
if(CUSOR->theroom.Sing==BOOKED)
{
if(RBOOKEDS==NULL)
{
RBOOKEDSCUSOR=malloc(sizeof(struct Roomp));
RBOOKEDSCUSOR->theroom=&(CUSOR->theroom);
RBOOKEDS=RBOOKEDSCUSOR;
RBOOKEDS->before=NULL;
RBOOKEDS->next=NULL;
}
else
{
RBOOKEDSCUSOR->next=malloc(sizeof(struct Roomp));
RBOOKEDSCUSOR->next->before=RBOOKEDSCUSOR;
RBOOKEDSCUSOR=RBOOKEDSCUSOR->next;
RBOOKEDSCUSOR->theroom=&(CUSOR->theroom);
RBOOKEDSCUSOR->next=NULL;
}
if(CBOOKEDS==NULL)
{
CBOOKEDSCUSOR=malloc(sizeof(struct Customers));
CBOOKEDSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
CBOOKEDS=CBOOKEDSCUSOR;
CBOOKEDS->before=NULL;
CBOOKEDS->next=NULL;
}
else
{
CBOOKEDSCUSOR->next=malloc(sizeof(struct Customers));
CBOOKEDSCUSOR->next->before=CBOOKEDSCUSOR;
CBOOKEDSCUSOR=CBOOKEDSCUSOR->next;
CBOOKEDSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
CBOOKEDSCUSOR->next=NULL;
}
if(ALLCUSTOMERS==NULL)
{
ALLCUSTOMERSCUSOR=malloc(sizeof(struct Customers));
ALLCUSTOMERSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
ALLCUSTOMERS=ALLCUSTOMERSCUSOR;
ALLCUSTOMERS->before=NULL;
ALLCUSTOMERS->next=NULL;
}
else
{
ALLCUSTOMERSCUSOR->next=malloc(sizeof(struct Customers));
ALLCUSTOMERSCUSOR->next->before=ALLCUSTOMERSCUSOR;
ALLCUSTOMERSCUSOR=ALLCUSTOMERSCUSOR->next;
ALLCUSTOMERSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
ALLCUSTOMERSCUSOR->next=NULL;
}
bookedcnt++;
roomcnt++;
customercnt++;
}
if(CUSOR->theroom.Sing==CHECKEDIN)
{
if(RCHECKEDINS==NULL)
{
RCHECKEDINSCUSOR=malloc(sizeof(struct Roomp));
RCHECKEDINSCUSOR->theroom=&CUSOR->theroom;
RCHECKEDINS=RCHECKEDINSCUSOR;
RCHECKEDINS->before=NULL;
RCHECKEDINS->next=NULL;
}
else
{
RCHECKEDINSCUSOR->next=malloc(sizeof(struct Roomp));
RCHECKEDINSCUSOR->next->before=RCHECKEDINSCUSOR;
RCHECKEDINSCUSOR=RCHECKEDINSCUSOR->next;
RCHECKEDINSCUSOR->theroom=&CUSOR->theroom;
RCHECKEDINSCUSOR->next=NULL;
}
if(CCHECKEDINS==NULL)
{
CCHECKEDINSCUSOR=malloc(sizeof(struct Customers));
CCHECKEDINSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
CCHECKEDINS=CCHECKEDINSCUSOR;
CCHECKEDINS->before=NULL;
CCHECKEDINS->next=NULL;
}
else
{
CCHECKEDINSCUSOR->next=malloc(sizeof(struct Customers));
CCHECKEDINSCUSOR->next->before=CCHECKEDINSCUSOR;
CCHECKEDINSCUSOR=CCHECKEDINSCUSOR->next;
CCHECKEDINSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
CCHECKEDINSCUSOR->next=NULL;
}
if(ALLCUSTOMERS==NULL)
{
ALLCUSTOMERSCUSOR=malloc(sizeof(struct Customers));
ALLCUSTOMERSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
ALLCUSTOMERS=ALLCUSTOMERSCUSOR;
ALLCUSTOMERS->before=NULL;
ALLCUSTOMERS->next=NULL;
}
else
{
ALLCUSTOMERSCUSOR->next=malloc(sizeof(struct Customers));
ALLCUSTOMERSCUSOR->next->before=ALLCUSTOMERSCUSOR;
ALLCUSTOMERSCUSOR=ALLCUSTOMERSCUSOR->next;
ALLCUSTOMERSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
ALLCUSTOMERSCUSOR->next=NULL;
}
checkedincnt++;
roomcnt++;
customercnt++;
}
CUSOR=CUSOR->next;
}
done=1;
}
ROOMCUSOR=ROOM;
printf("\t\t==============================================\n");
printf("\t\t 房间号 房间电话 房间价格 房间状态 \n");
printf("\t\t*--------------------------------------------*\n");
while(ROOMCUSOR!=NULL)
{
switch(ROOMCUSOR->theroom.Sing)
{
case EMPTY: {strcpy(roomstatus,"空 闲");break;}
case BOOKED: {strcpy(roomstatus,"已预订");break;}
default: {strcpy(roomstatus,"已入住");break;}
}
printf("\t\t %4s %7s %4u %3s \n",ROOMCUSOR->theroom.Room_ID,ROOMCUSOR->theroom.Tel,ROOMCUSOR->theroom.Price,roomstatus);
printf("\t\t*--------------------------------------------*\n");
ROOMCUSOR=ROOMCUSOR->next;
}
printf("\t\t 合计: %3u 间。\n",roomcnt);
printf("\t\t==============================================\n");
ROOMCUSOR=NULL;
break;
}

2007-07-17 21:27
mzjllh
Rank: 2
来 自:江苏扬州
等 级:论坛游民
帖 子:76
专家分:41
注 册:2007-2-8
收藏
得分:0 
case '3':
{
printf("\n正在统计...\n");
if(!done)
{
CUSOR=ROOM;
while(CUSOR!=NULL)
{
if(CUSOR->theroom.Sing==EMPTY)
{
if(REMPTYS==NULL)
{
REMPTYSCUSOR=malloc(sizeof(struct Roomp));
REMPTYSCUSOR->theroom=&(CUSOR->theroom);
REMPTYS=REMPTYSCUSOR;
REMPTYS->before=NULL;
REMPTYS->next=NULL;
}
else
{
REMPTYSCUSOR->next=malloc(sizeof(struct Roomp));
REMPTYSCUSOR->next->before=REMPTYSCUSOR;
REMPTYSCUSOR=REMPTYSCUSOR->next;
REMPTYSCUSOR->theroom=&CUSOR->theroom;
REMPTYSCUSOR->next=NULL;
}
emptycnt++;
roomcnt++;
}
if(CUSOR->theroom.Sing==BOOKED)
{
if(RBOOKEDS==NULL)
{
RBOOKEDSCUSOR=malloc(sizeof(struct Roomp));
RBOOKEDSCUSOR->theroom=&(CUSOR->theroom);
RBOOKEDS=RBOOKEDSCUSOR;
RBOOKEDS->before=NULL;
RBOOKEDS->next=NULL;
}
else
{
RBOOKEDSCUSOR->next=malloc(sizeof(struct Roomp));
RBOOKEDSCUSOR->next->before=RBOOKEDSCUSOR;
RBOOKEDSCUSOR=RBOOKEDSCUSOR->next;
RBOOKEDSCUSOR->theroom=&(CUSOR->theroom);
RBOOKEDSCUSOR->next=NULL;
}
if(CBOOKEDS==NULL)
{
CBOOKEDSCUSOR=malloc(sizeof(struct Customers));
CBOOKEDSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
CBOOKEDS=CBOOKEDSCUSOR;
CBOOKEDS->before=NULL;
CBOOKEDS->next=NULL;
}
else
{
CBOOKEDSCUSOR->next=malloc(sizeof(struct Customers));
CBOOKEDSCUSOR->next->before=CBOOKEDSCUSOR;
CBOOKEDSCUSOR=CBOOKEDSCUSOR->next;
CBOOKEDSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
CBOOKEDSCUSOR->next=NULL;
}
if(ALLCUSTOMERS==NULL)
{
ALLCUSTOMERSCUSOR=malloc(sizeof(struct Customers));
ALLCUSTOMERSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
ALLCUSTOMERS=ALLCUSTOMERSCUSOR;
ALLCUSTOMERS->before=NULL;
ALLCUSTOMERS->next=NULL;
}
else
{
ALLCUSTOMERSCUSOR->next=malloc(sizeof(struct Customers));
ALLCUSTOMERSCUSOR->next->before=ALLCUSTOMERSCUSOR;
ALLCUSTOMERSCUSOR=ALLCUSTOMERSCUSOR->next;
ALLCUSTOMERSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
ALLCUSTOMERSCUSOR->next=NULL;
}
bookedcnt++;
roomcnt++;
customercnt++;
}
if(CUSOR->theroom.Sing==CHECKEDIN)
{
if(RCHECKEDINS==NULL)
{
RCHECKEDINSCUSOR=malloc(sizeof(struct Roomp));
RCHECKEDINSCUSOR->theroom=&CUSOR->theroom;
RCHECKEDINS=RCHECKEDINSCUSOR;
RCHECKEDINS->before=NULL;
RCHECKEDINS->next=NULL;
}
else
{
RCHECKEDINSCUSOR->next=malloc(sizeof(struct Roomp));
RCHECKEDINSCUSOR->next->before=RCHECKEDINSCUSOR;
RCHECKEDINSCUSOR=RCHECKEDINSCUSOR->next;
RCHECKEDINSCUSOR->theroom=&CUSOR->theroom;
RCHECKEDINSCUSOR->next=NULL;
}
if(CCHECKEDINS==NULL)
{
CCHECKEDINSCUSOR=malloc(sizeof(struct Customers));
CCHECKEDINSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
CCHECKEDINS=CCHECKEDINSCUSOR;
CCHECKEDINS->before=NULL;
CCHECKEDINS->next=NULL;
}
else
{
CCHECKEDINSCUSOR->next=malloc(sizeof(struct Customers));
CCHECKEDINSCUSOR->next->before=CCHECKEDINSCUSOR;
CCHECKEDINSCUSOR=CCHECKEDINSCUSOR->next;
CCHECKEDINSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
CCHECKEDINSCUSOR->next=NULL;
}
if(ALLCUSTOMERS==NULL)
{
ALLCUSTOMERSCUSOR=malloc(sizeof(struct Customers));
ALLCUSTOMERSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
ALLCUSTOMERS=ALLCUSTOMERSCUSOR;
ALLCUSTOMERS->before=NULL;
ALLCUSTOMERS->next=NULL;
}
else
{
ALLCUSTOMERSCUSOR->next=malloc(sizeof(struct Customers));
ALLCUSTOMERSCUSOR->next->before=ALLCUSTOMERSCUSOR;
ALLCUSTOMERSCUSOR=ALLCUSTOMERSCUSOR->next;
ALLCUSTOMERSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
ALLCUSTOMERSCUSOR->next=NULL;
}
checkedincnt++;
roomcnt++;
customercnt++;
}
CUSOR=CUSOR->next;
}
done=1;
}
RPCUSOR=REMPTYS;
printf("\t\t\t ======空闲客房统计======\n");
printf("\t\t==============================================\n");
printf("\t\t 房间号 房间电话 房间价格 房间状态 \n");
printf("\t\t*--------------------------------------------*\n");
while(RPCUSOR!=NULL)
{
strcpy(roomstatus,"空 闲");
printf("\t\t %4s %7s %4u %3s \n",RPCUSOR->theroom->Room_ID,RPCUSOR->theroom->Tel,RPCUSOR->theroom->Price,roomstatus);
printf("\t\t*--------------------------------------------*\n");
RPCUSOR=RPCUSOR->next;
}
printf("\t\t 合计: %3u 间。\n",emptycnt);
printf("\t\t==============================================\n");
RPCUSOR=NULL;
break;
}
case '4':
{
printf("\n正在统计...\n");
if(!done)
{
CUSOR=ROOM;
while(CUSOR!=NULL)
{
if(CUSOR->theroom.Sing==EMPTY)
{
if(REMPTYS==NULL)
{
REMPTYSCUSOR=malloc(sizeof(struct Roomp));
REMPTYSCUSOR->theroom=&(CUSOR->theroom);
REMPTYS=REMPTYSCUSOR;
REMPTYS->before=NULL;
REMPTYS->next=NULL;
}
else
{
REMPTYSCUSOR->next=malloc(sizeof(struct Roomp));
REMPTYSCUSOR->next->before=REMPTYSCUSOR;
REMPTYSCUSOR=REMPTYSCUSOR->next;
REMPTYSCUSOR->theroom=&CUSOR->theroom;
REMPTYSCUSOR->next=NULL;
}
emptycnt++;
roomcnt++;
}
if(CUSOR->theroom.Sing==BOOKED)
{
if(RBOOKEDS==NULL)
{
RBOOKEDSCUSOR=malloc(sizeof(struct Roomp));
RBOOKEDSCUSOR->theroom=&(CUSOR->theroom);
RBOOKEDS=RBOOKEDSCUSOR;
RBOOKEDS->before=NULL;
RBOOKEDS->next=NULL;
}
else
{
RBOOKEDSCUSOR->next=malloc(sizeof(struct Roomp));
RBOOKEDSCUSOR->next->before=RBOOKEDSCUSOR;
RBOOKEDSCUSOR=RBOOKEDSCUSOR->next;
RBOOKEDSCUSOR->theroom=&(CUSOR->theroom);
RBOOKEDSCUSOR->next=NULL;
}
if(CBOOKEDS==NULL)
{
CBOOKEDSCUSOR=malloc(sizeof(struct Customers));
CBOOKEDSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
CBOOKEDS=CBOOKEDSCUSOR;
CBOOKEDS->before=NULL;
CBOOKEDS->next=NULL;
}
else
{
CBOOKEDSCUSOR->next=malloc(sizeof(struct Customers));
CBOOKEDSCUSOR->next->before=CBOOKEDSCUSOR;
CBOOKEDSCUSOR=CBOOKEDSCUSOR->next;
CBOOKEDSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
CBOOKEDSCUSOR->next=NULL;
}
if(ALLCUSTOMERS==NULL)
{
ALLCUSTOMERSCUSOR=malloc(sizeof(struct Customers));
ALLCUSTOMERSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
ALLCUSTOMERS=ALLCUSTOMERSCUSOR;
ALLCUSTOMERS->before=NULL;
ALLCUSTOMERS->next=NULL;
}
else
{
ALLCUSTOMERSCUSOR->next=malloc(sizeof(struct Customers));
ALLCUSTOMERSCUSOR->next->before=ALLCUSTOMERSCUSOR;
ALLCUSTOMERSCUSOR=ALLCUSTOMERSCUSOR->next;
ALLCUSTOMERSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
ALLCUSTOMERSCUSOR->next=NULL;
}
bookedcnt++;
roomcnt++;
customercnt++;
}
if(CUSOR->theroom.Sing==CHECKEDIN)
{
if(RCHECKEDINS==NULL)
{
RCHECKEDINSCUSOR=malloc(sizeof(struct Roomp));
RCHECKEDINSCUSOR->theroom=&CUSOR->theroom;
RCHECKEDINS=RCHECKEDINSCUSOR;
RCHECKEDINS->before=NULL;
RCHECKEDINS->next=NULL;
}
else
{
RCHECKEDINSCUSOR->next=malloc(sizeof(struct Roomp));
RCHECKEDINSCUSOR->next->before=RCHECKEDINSCUSOR;
RCHECKEDINSCUSOR=RCHECKEDINSCUSOR->next;
RCHECKEDINSCUSOR->theroom=&CUSOR->theroom;
RCHECKEDINSCUSOR->next=NULL;
}
if(CCHECKEDINS==NULL)
{
CCHECKEDINSCUSOR=malloc(sizeof(struct Customers));
CCHECKEDINSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
CCHECKEDINS=CCHECKEDINSCUSOR;
CCHECKEDINS->before=NULL;
CCHECKEDINS->next=NULL;
}
else
{
CCHECKEDINSCUSOR->next=malloc(sizeof(struct Customers));
CCHECKEDINSCUSOR->next->before=CCHECKEDINSCUSOR;
CCHECKEDINSCUSOR=CCHECKEDINSCUSOR->next;
CCHECKEDINSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
CCHECKEDINSCUSOR->next=NULL;
}
if(ALLCUSTOMERS==NULL)
{
ALLCUSTOMERSCUSOR=malloc(sizeof(struct Customers));
ALLCUSTOMERSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
ALLCUSTOMERS=ALLCUSTOMERSCUSOR;
ALLCUSTOMERS->before=NULL;
ALLCUSTOMERS->next=NULL;
}
else
{
ALLCUSTOMERSCUSOR->next=malloc(sizeof(struct Customers));
ALLCUSTOMERSCUSOR->next->before=ALLCUSTOMERSCUSOR;
ALLCUSTOMERSCUSOR=ALLCUSTOMERSCUSOR->next;
ALLCUSTOMERSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
ALLCUSTOMERSCUSOR->next=NULL;
}
checkedincnt++;
roomcnt++;
customercnt++;
}
CUSOR=CUSOR->next;
}
done=1;
}
RPCUSOR=RBOOKEDS;
printf("\t\t\t ======预订客房统计======\n");
printf("\t\t==============================================\n");
printf("\t\t 房间号 房间电话 房间价格 房间状态 \n");
printf("\t\t*--------------------------------------------*\n");
while(RPCUSOR!=NULL)
{
strcpy(roomstatus,"已预订");
printf("\t\t %4s %7s %4u %3s \n",RPCUSOR->theroom->Room_ID,RPCUSOR->theroom->Tel,RPCUSOR->theroom->Price,roomstatus);
printf("\t\t*--------------------------------------------*\n");
RPCUSOR=RPCUSOR->next;
}
printf("\t\t 合计: %3u 间。\n",bookedcnt);
printf("\t\t==============================================\n");
RPCUSOR=NULL;
break;
}
2007-07-17 21:28
mzjllh
Rank: 2
来 自:江苏扬州
等 级:论坛游民
帖 子:76
专家分:41
注 册:2007-2-8
收藏
得分:0 
case '5':
{
printf("\n正在统计...\n");
if(!done)
{
CUSOR=ROOM;
while(CUSOR!=NULL)
{
if(CUSOR->theroom.Sing==EMPTY)
{
if(REMPTYS==NULL)
{
REMPTYSCUSOR=malloc(sizeof(struct Roomp));
REMPTYSCUSOR->theroom=&(CUSOR->theroom);
REMPTYS=REMPTYSCUSOR;
REMPTYS->before=NULL;
REMPTYS->next=NULL;
}
else
{
REMPTYSCUSOR->next=malloc(sizeof(struct Roomp));
REMPTYSCUSOR->next->before=REMPTYSCUSOR;
REMPTYSCUSOR=REMPTYSCUSOR->next;
REMPTYSCUSOR->theroom=&CUSOR->theroom;
REMPTYSCUSOR->next=NULL;
}
emptycnt++;
roomcnt++;
}
if(CUSOR->theroom.Sing==BOOKED)
{
if(RBOOKEDS==NULL)
{
RBOOKEDSCUSOR=malloc(sizeof(struct Roomp));
RBOOKEDSCUSOR->theroom=&(CUSOR->theroom);
RBOOKEDS=RBOOKEDSCUSOR;
RBOOKEDS->before=NULL;
RBOOKEDS->next=NULL;
}
else
{
RBOOKEDSCUSOR->next=malloc(sizeof(struct Roomp));
RBOOKEDSCUSOR->next->before=RBOOKEDSCUSOR;
RBOOKEDSCUSOR=RBOOKEDSCUSOR->next;
RBOOKEDSCUSOR->theroom=&(CUSOR->theroom);
RBOOKEDSCUSOR->next=NULL;
}
if(CBOOKEDS==NULL)
{
CBOOKEDSCUSOR=malloc(sizeof(struct Customers));
CBOOKEDSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
CBOOKEDS=CBOOKEDSCUSOR;
CBOOKEDS->before=NULL;
CBOOKEDS->next=NULL;
}
else
{
CBOOKEDSCUSOR->next=malloc(sizeof(struct Customers));
CBOOKEDSCUSOR->next->before=CBOOKEDSCUSOR;
CBOOKEDSCUSOR=CBOOKEDSCUSOR->next;
CBOOKEDSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
CBOOKEDSCUSOR->next=NULL;
}
if(ALLCUSTOMERS==NULL)
{
ALLCUSTOMERSCUSOR=malloc(sizeof(struct Customers));
ALLCUSTOMERSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
ALLCUSTOMERS=ALLCUSTOMERSCUSOR;
ALLCUSTOMERS->before=NULL;
ALLCUSTOMERS->next=NULL;
}
else
{
ALLCUSTOMERSCUSOR->next=malloc(sizeof(struct Customers));
ALLCUSTOMERSCUSOR->next->before=ALLCUSTOMERSCUSOR;
ALLCUSTOMERSCUSOR=ALLCUSTOMERSCUSOR->next;
ALLCUSTOMERSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
ALLCUSTOMERSCUSOR->next=NULL;
}
bookedcnt++;
roomcnt++;
customercnt++;
}
if(CUSOR->theroom.Sing==CHECKEDIN)
{
if(RCHECKEDINS==NULL)
{
RCHECKEDINSCUSOR=malloc(sizeof(struct Roomp));
RCHECKEDINSCUSOR->theroom=&CUSOR->theroom;
RCHECKEDINS=RCHECKEDINSCUSOR;
RCHECKEDINS->before=NULL;
RCHECKEDINS->next=NULL;
}
else
{
RCHECKEDINSCUSOR->next=malloc(sizeof(struct Roomp));
RCHECKEDINSCUSOR->next->before=RCHECKEDINSCUSOR;
RCHECKEDINSCUSOR=RCHECKEDINSCUSOR->next;
RCHECKEDINSCUSOR->theroom=&CUSOR->theroom;
RCHECKEDINSCUSOR->next=NULL;
}
if(CCHECKEDINS==NULL)
{
CCHECKEDINSCUSOR=malloc(sizeof(struct Customers));
CCHECKEDINSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
CCHECKEDINS=CCHECKEDINSCUSOR;
CCHECKEDINS->before=NULL;
CCHECKEDINS->next=NULL;
}
else
{
CCHECKEDINSCUSOR->next=malloc(sizeof(struct Customers));
CCHECKEDINSCUSOR->next->before=CCHECKEDINSCUSOR;
CCHECKEDINSCUSOR=CCHECKEDINSCUSOR->next;
CCHECKEDINSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
CCHECKEDINSCUSOR->next=NULL;
}
if(ALLCUSTOMERS==NULL)
{
ALLCUSTOMERSCUSOR=malloc(sizeof(struct Customers));
ALLCUSTOMERSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
ALLCUSTOMERS=ALLCUSTOMERSCUSOR;
ALLCUSTOMERS->before=NULL;
ALLCUSTOMERS->next=NULL;
}
else
{
ALLCUSTOMERSCUSOR->next=malloc(sizeof(struct Customers));
ALLCUSTOMERSCUSOR->next->before=ALLCUSTOMERSCUSOR;
ALLCUSTOMERSCUSOR=ALLCUSTOMERSCUSOR->next;
ALLCUSTOMERSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
ALLCUSTOMERSCUSOR->next=NULL;
}
checkedincnt++;
roomcnt++;
customercnt++;
}
CUSOR=CUSOR->next;
}
done=1;
}
RPCUSOR=RCHECKEDINS;
printf("\t\t\t ======入住客房统计======\n");
printf("\t\t==============================================\n");
printf("\t\t 房间号 房间电话 房间价格 房间状态 \n");
printf("\t\t*--------------------------------------------*\n");
while(RPCUSOR!=NULL)
{
strcpy(roomstatus,"已入住");
printf("\t\t %4s %7s %4u %3s \n",RPCUSOR->theroom->Room_ID,RPCUSOR->theroom->Tel,RPCUSOR->theroom->Price,roomstatus);
printf("\t\t*--------------------------------------------*\n");
RPCUSOR=RPCUSOR->next;
}
printf("\t\t 合计: %3u 间。\n",checkedincnt);
printf("\t\t==============================================\n");
RPCUSOR=NULL;
break;
}
case '6':
{
printf("\n正在统计...\n");
if(!done)
{
CUSOR=ROOM;
while(CUSOR!=NULL)
{
if(CUSOR->theroom.Sing==EMPTY)
{
if(REMPTYS==NULL)
{
REMPTYSCUSOR=malloc(sizeof(struct Roomp));
REMPTYSCUSOR->theroom=&(CUSOR->theroom);
REMPTYS=REMPTYSCUSOR;
REMPTYS->before=NULL;
REMPTYS->next=NULL;
}
else
{
REMPTYSCUSOR->next=malloc(sizeof(struct Roomp));
REMPTYSCUSOR->next->before=REMPTYSCUSOR;
REMPTYSCUSOR=REMPTYSCUSOR->next;
REMPTYSCUSOR->theroom=&CUSOR->theroom;
REMPTYSCUSOR->next=NULL;
}
emptycnt++;
roomcnt++;
}
if(CUSOR->theroom.Sing==BOOKED)
{
if(RBOOKEDS==NULL)
{
RBOOKEDSCUSOR=malloc(sizeof(struct Roomp));
RBOOKEDSCUSOR->theroom=&(CUSOR->theroom);
RBOOKEDS=RBOOKEDSCUSOR;
RBOOKEDS->before=NULL;
RBOOKEDS->next=NULL;
}
else
{
RBOOKEDSCUSOR->next=malloc(sizeof(struct Roomp));
RBOOKEDSCUSOR->next->before=RBOOKEDSCUSOR;
RBOOKEDSCUSOR=RBOOKEDSCUSOR->next;
RBOOKEDSCUSOR->theroom=&(CUSOR->theroom);
RBOOKEDSCUSOR->next=NULL;
}
if(CBOOKEDS==NULL)
{
CBOOKEDSCUSOR=malloc(sizeof(struct Customers));
CBOOKEDSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
CBOOKEDS=CBOOKEDSCUSOR;
CBOOKEDS->before=NULL;
CBOOKEDS->next=NULL;
}
else
{
CBOOKEDSCUSOR->next=malloc(sizeof(struct Customers));
CBOOKEDSCUSOR->next->before=CBOOKEDSCUSOR;
CBOOKEDSCUSOR=CBOOKEDSCUSOR->next;
CBOOKEDSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
CBOOKEDSCUSOR->next=NULL;
}
if(ALLCUSTOMERS==NULL)
{
ALLCUSTOMERSCUSOR=malloc(sizeof(struct Customers));
ALLCUSTOMERSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
ALLCUSTOMERS=ALLCUSTOMERSCUSOR;
ALLCUSTOMERS->before=NULL;
ALLCUSTOMERS->next=NULL;
}
else
{
ALLCUSTOMERSCUSOR->next=malloc(sizeof(struct Customers));
ALLCUSTOMERSCUSOR->next->before=ALLCUSTOMERSCUSOR;
ALLCUSTOMERSCUSOR=ALLCUSTOMERSCUSOR->next;
ALLCUSTOMERSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
ALLCUSTOMERSCUSOR->next=NULL;
}
bookedcnt++;
roomcnt++;
customercnt++;
}
if(CUSOR->theroom.Sing==CHECKEDIN)
{
if(RCHECKEDINS==NULL)
{
RCHECKEDINSCUSOR=malloc(sizeof(struct Roomp));
RCHECKEDINSCUSOR->theroom=&CUSOR->theroom;
RCHECKEDINS=RCHECKEDINSCUSOR;
RCHECKEDINS->before=NULL;
RCHECKEDINS->next=NULL;
}
else
{
RCHECKEDINSCUSOR->next=malloc(sizeof(struct Roomp));
RCHECKEDINSCUSOR->next->before=RCHECKEDINSCUSOR;
RCHECKEDINSCUSOR=RCHECKEDINSCUSOR->next;
RCHECKEDINSCUSOR->theroom=&CUSOR->theroom;
RCHECKEDINSCUSOR->next=NULL;
}
if(CCHECKEDINS==NULL)
{
CCHECKEDINSCUSOR=malloc(sizeof(struct Customers));
CCHECKEDINSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
CCHECKEDINS=CCHECKEDINSCUSOR;
CCHECKEDINS->before=NULL;
CCHECKEDINS->next=NULL;
}
else
{
CCHECKEDINSCUSOR->next=malloc(sizeof(struct Customers));
CCHECKEDINSCUSOR->next->before=CCHECKEDINSCUSOR;
CCHECKEDINSCUSOR=CCHECKEDINSCUSOR->next;
CCHECKEDINSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
CCHECKEDINSCUSOR->next=NULL;
}
if(ALLCUSTOMERS==NULL)
{
ALLCUSTOMERSCUSOR=malloc(sizeof(struct Customers));
ALLCUSTOMERSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
ALLCUSTOMERS=ALLCUSTOMERSCUSOR;
ALLCUSTOMERS->before=NULL;
ALLCUSTOMERS->next=NULL;
}
else
{
ALLCUSTOMERSCUSOR->next=malloc(sizeof(struct Customers));
ALLCUSTOMERSCUSOR->next->before=ALLCUSTOMERSCUSOR;
ALLCUSTOMERSCUSOR=ALLCUSTOMERSCUSOR->next;
ALLCUSTOMERSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
ALLCUSTOMERSCUSOR->next=NULL;
}
checkedincnt++;
roomcnt++;
customercnt++;
}
CUSOR=CUSOR->next;
}
done=1;
}
printf("\t\t\t ======顾客概况统计======\n");
printf("\t\t =============================================\n");
printf("\t\t 总 数 预 订 入 住 \n");
printf("\t\t =============================================\n");
printf("\t\t %3u %3u %3u \n",customercnt,bookedcnt,checkedincnt);
printf("\t\t =============================================\n");
break;
}
2007-07-17 21:28
mzjllh
Rank: 2
来 自:江苏扬州
等 级:论坛游民
帖 子:76
专家分:41
注 册:2007-2-8
收藏
得分:0 
case '7':
{
printf("\n正在统计...\n");
if(!done)
{
CUSOR=ROOM;
while(CUSOR!=NULL)
{
if(CUSOR->theroom.Sing==EMPTY)
{
if(REMPTYS==NULL)
{
REMPTYSCUSOR=malloc(sizeof(struct Roomp));
REMPTYSCUSOR->theroom=&(CUSOR->theroom);
REMPTYS=REMPTYSCUSOR;
REMPTYS->before=NULL;
REMPTYS->next=NULL;
}
else
{
REMPTYSCUSOR->next=malloc(sizeof(struct Roomp));
REMPTYSCUSOR->next->before=REMPTYSCUSOR;
REMPTYSCUSOR=REMPTYSCUSOR->next;
REMPTYSCUSOR->theroom=&CUSOR->theroom;
REMPTYSCUSOR->next=NULL;
}
emptycnt++;
roomcnt++;
}
if(CUSOR->theroom.Sing==BOOKED)
{
if(RBOOKEDS==NULL)
{
RBOOKEDSCUSOR=malloc(sizeof(struct Roomp));
RBOOKEDSCUSOR->theroom=&(CUSOR->theroom);
RBOOKEDS=RBOOKEDSCUSOR;
RBOOKEDS->before=NULL;
RBOOKEDS->next=NULL;
}
else
{
RBOOKEDSCUSOR->next=malloc(sizeof(struct Roomp));
RBOOKEDSCUSOR->next->before=RBOOKEDSCUSOR;
RBOOKEDSCUSOR=RBOOKEDSCUSOR->next;
RBOOKEDSCUSOR->theroom=&(CUSOR->theroom);
RBOOKEDSCUSOR->next=NULL;
}
if(CBOOKEDS==NULL)
{
CBOOKEDSCUSOR=malloc(sizeof(struct Customers));
CBOOKEDSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
CBOOKEDS=CBOOKEDSCUSOR;
CBOOKEDS->before=NULL;
CBOOKEDS->next=NULL;
}
else
{
CBOOKEDSCUSOR->next=malloc(sizeof(struct Customers));
CBOOKEDSCUSOR->next->before=CBOOKEDSCUSOR;
CBOOKEDSCUSOR=CBOOKEDSCUSOR->next;
CBOOKEDSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
CBOOKEDSCUSOR->next=NULL;
}
if(ALLCUSTOMERS==NULL)
{
ALLCUSTOMERSCUSOR=malloc(sizeof(struct Customers));
ALLCUSTOMERSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
ALLCUSTOMERS=ALLCUSTOMERSCUSOR;
ALLCUSTOMERS->before=NULL;
ALLCUSTOMERS->next=NULL;
}
else
{
ALLCUSTOMERSCUSOR->next=malloc(sizeof(struct Customers));
ALLCUSTOMERSCUSOR->next->before=ALLCUSTOMERSCUSOR;
ALLCUSTOMERSCUSOR=ALLCUSTOMERSCUSOR->next;
ALLCUSTOMERSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
ALLCUSTOMERSCUSOR->next=NULL;
}
bookedcnt++;
roomcnt++;
customercnt++;
}
if(CUSOR->theroom.Sing==CHECKEDIN)
{
if(RCHECKEDINS==NULL)
{
RCHECKEDINSCUSOR=malloc(sizeof(struct Roomp));
RCHECKEDINSCUSOR->theroom=&CUSOR->theroom;
RCHECKEDINS=RCHECKEDINSCUSOR;
RCHECKEDINS->before=NULL;
RCHECKEDINS->next=NULL;
}
else
{
RCHECKEDINSCUSOR->next=malloc(sizeof(struct Roomp));
RCHECKEDINSCUSOR->next->before=RCHECKEDINSCUSOR;
RCHECKEDINSCUSOR=RCHECKEDINSCUSOR->next;
RCHECKEDINSCUSOR->theroom=&CUSOR->theroom;
RCHECKEDINSCUSOR->next=NULL;
}
if(CCHECKEDINS==NULL)
{
CCHECKEDINSCUSOR=malloc(sizeof(struct Customers));
CCHECKEDINSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
CCHECKEDINS=CCHECKEDINSCUSOR;
CCHECKEDINS->before=NULL;
CCHECKEDINS->next=NULL;
}
else
{
CCHECKEDINSCUSOR->next=malloc(sizeof(struct Customers));
CCHECKEDINSCUSOR->next->before=CCHECKEDINSCUSOR;
CCHECKEDINSCUSOR=CCHECKEDINSCUSOR->next;
CCHECKEDINSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
CCHECKEDINSCUSOR->next=NULL;
}
if(ALLCUSTOMERS==NULL)
{
ALLCUSTOMERSCUSOR=malloc(sizeof(struct Customers));
ALLCUSTOMERSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
ALLCUSTOMERS=ALLCUSTOMERSCUSOR;
ALLCUSTOMERS->before=NULL;
ALLCUSTOMERS->next=NULL;
}
else
{
ALLCUSTOMERSCUSOR->next=malloc(sizeof(struct Customers));
ALLCUSTOMERSCUSOR->next->before=ALLCUSTOMERSCUSOR;
ALLCUSTOMERSCUSOR=ALLCUSTOMERSCUSOR->next;
ALLCUSTOMERSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
ALLCUSTOMERSCUSOR->next=NULL;
}
checkedincnt++;
roomcnt++;
customercnt++;
}
CUSOR=CUSOR->next;
}
done=1;
}
printf("\t\t\t ======所有顾客统计======\n");
printf("\t\t==============================================\n");
printf("\t\t 姓 名 性 别 身份证号 登记时间 \n");
printf("\t\t*--------------------------------------------*\n");
CPCUSOR=ALLCUSTOMERS;
while(CPCUSOR!=NULL)
{
printf("\t\t %6s %2s %18s %d/%d/%d\n",CPCUSOR->thecustomer->Name,CPCUSOR->thecustomer->Sex,CPCUSOR->thecustomer->ID_card,CPCUSOR->thecustomer->year,CPCUSOR->thecustomer->month,CPCUSOR->thecustomer->day);
printf("\t\t*--------------------------------------------*\n");
CPCUSOR=CPCUSOR->next;
}
printf("\t\t 合计: %3u 个\n",customercnt);
printf("\t\t==============================================\n");
break;
}
case '8':
{
printf("\n正在统计...\n");
if(!done)
{
CUSOR=ROOM;
while(CUSOR!=NULL)
{
if(CUSOR->theroom.Sing==EMPTY)
{
if(REMPTYS==NULL)
{
REMPTYSCUSOR=malloc(sizeof(struct Roomp));
REMPTYSCUSOR->theroom=&(CUSOR->theroom);
REMPTYS=REMPTYSCUSOR;
REMPTYS->before=NULL;
REMPTYS->next=NULL;
}
else
{
REMPTYSCUSOR->next=malloc(sizeof(struct Roomp));
REMPTYSCUSOR->next->before=REMPTYSCUSOR;
REMPTYSCUSOR=REMPTYSCUSOR->next;
REMPTYSCUSOR->theroom=&CUSOR->theroom;
REMPTYSCUSOR->next=NULL;
}
emptycnt++;
roomcnt++;
}
if(CUSOR->theroom.Sing==BOOKED)
{
if(RBOOKEDS==NULL)
{
RBOOKEDSCUSOR=malloc(sizeof(struct Roomp));
RBOOKEDSCUSOR->theroom=&(CUSOR->theroom);
RBOOKEDS=RBOOKEDSCUSOR;
RBOOKEDS->before=NULL;
RBOOKEDS->next=NULL;
}
else
{
RBOOKEDSCUSOR->next=malloc(sizeof(struct Roomp));
RBOOKEDSCUSOR->next->before=RBOOKEDSCUSOR;
RBOOKEDSCUSOR=RBOOKEDSCUSOR->next;
RBOOKEDSCUSOR->theroom=&(CUSOR->theroom);
RBOOKEDSCUSOR->next=NULL;
}
if(CBOOKEDS==NULL)
{
CBOOKEDSCUSOR=malloc(sizeof(struct Customers));
CBOOKEDSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
CBOOKEDS=CBOOKEDSCUSOR;
CBOOKEDS->before=NULL;
CBOOKEDS->next=NULL;
}
else
{
CBOOKEDSCUSOR->next=malloc(sizeof(struct Customers));
CBOOKEDSCUSOR->next->before=CBOOKEDSCUSOR;
CBOOKEDSCUSOR=CBOOKEDSCUSOR->next;
CBOOKEDSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
CBOOKEDSCUSOR->next=NULL;
}
if(ALLCUSTOMERS==NULL)
{
ALLCUSTOMERSCUSOR=malloc(sizeof(struct Customers));
ALLCUSTOMERSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
ALLCUSTOMERS=ALLCUSTOMERSCUSOR;
ALLCUSTOMERS->before=NULL;
ALLCUSTOMERS->next=NULL;
}
else
{
ALLCUSTOMERSCUSOR->next=malloc(sizeof(struct Customers));
ALLCUSTOMERSCUSOR->next->before=ALLCUSTOMERSCUSOR;
ALLCUSTOMERSCUSOR=ALLCUSTOMERSCUSOR->next;
ALLCUSTOMERSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
ALLCUSTOMERSCUSOR->next=NULL;
}
bookedcnt++;
roomcnt++;
customercnt++;
}
if(CUSOR->theroom.Sing==CHECKEDIN)
{
if(RCHECKEDINS==NULL)
{
RCHECKEDINSCUSOR=malloc(sizeof(struct Roomp));
RCHECKEDINSCUSOR->theroom=&CUSOR->theroom;
RCHECKEDINS=RCHECKEDINSCUSOR;
RCHECKEDINS->before=NULL;
RCHECKEDINS->next=NULL;
}
else
{
RCHECKEDINSCUSOR->next=malloc(sizeof(struct Roomp));
RCHECKEDINSCUSOR->next->before=RCHECKEDINSCUSOR;
RCHECKEDINSCUSOR=RCHECKEDINSCUSOR->next;
RCHECKEDINSCUSOR->theroom=&CUSOR->theroom;
RCHECKEDINSCUSOR->next=NULL;
}
if(CCHECKEDINS==NULL)
{
CCHECKEDINSCUSOR=malloc(sizeof(struct Customers));
CCHECKEDINSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
CCHECKEDINS=CCHECKEDINSCUSOR;
CCHECKEDINS->before=NULL;
CCHECKEDINS->next=NULL;
}
else
{
CCHECKEDINSCUSOR->next=malloc(sizeof(struct Customers));
CCHECKEDINSCUSOR->next->before=CCHECKEDINSCUSOR;
CCHECKEDINSCUSOR=CCHECKEDINSCUSOR->next;
CCHECKEDINSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
CCHECKEDINSCUSOR->next=NULL;
}
if(ALLCUSTOMERS==NULL)
{
ALLCUSTOMERSCUSOR=malloc(sizeof(struct Customers));
ALLCUSTOMERSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
ALLCUSTOMERS=ALLCUSTOMERSCUSOR;
ALLCUSTOMERS->before=NULL;
ALLCUSTOMERS->next=NULL;
}
else
{
ALLCUSTOMERSCUSOR->next=malloc(sizeof(struct Customers));
ALLCUSTOMERSCUSOR->next->before=ALLCUSTOMERSCUSOR;
ALLCUSTOMERSCUSOR=ALLCUSTOMERSCUSOR->next;
ALLCUSTOMERSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
ALLCUSTOMERSCUSOR->next=NULL;
}
checkedincnt++;
roomcnt++;
customercnt++;
}
CUSOR=CUSOR->next;
}
done=1;
}
printf("\t\t\t ======订房顾客统计======\n");
printf("\t\t==============================================\n");
printf("\t\t 姓 名 性 别 身份证号 登记时间 \n");
printf("\t\t*--------------------------------------------*\n");
CPCUSOR=CBOOKEDS;
while(CPCUSOR!=NULL)
{
printf("\t\t %6s %2s %18s %d/%d/%d\n",CPCUSOR->thecustomer->Name,CPCUSOR->thecustomer->Sex,CPCUSOR->thecustomer->ID_card,CPCUSOR->thecustomer->year,CPCUSOR->thecustomer->month,CPCUSOR->thecustomer->day);
printf("\t\t*--------------------------------------------*\n");
CPCUSOR=CPCUSOR->next;
}
printf("\t\t 合计: %3u 个\n",bookedcnt);
printf("\t\t==============================================\n");
break;
}
2007-07-17 21:28
mzjllh
Rank: 2
来 自:江苏扬州
等 级:论坛游民
帖 子:76
专家分:41
注 册:2007-2-8
收藏
得分:0 
case '9':
{
printf("\n正在统计...\n");
if(!done)
{
CUSOR=ROOM;
while(CUSOR!=NULL)
{
if(CUSOR->theroom.Sing==EMPTY)
{
if(REMPTYS==NULL)
{
REMPTYSCUSOR=malloc(sizeof(struct Roomp));
REMPTYSCUSOR->theroom=&(CUSOR->theroom);
REMPTYS=REMPTYSCUSOR;
REMPTYS->before=NULL;
REMPTYS->next=NULL;
}
else
{
REMPTYSCUSOR->next=malloc(sizeof(struct Roomp));
REMPTYSCUSOR->next->before=REMPTYSCUSOR;
REMPTYSCUSOR=REMPTYSCUSOR->next;
REMPTYSCUSOR->theroom=&CUSOR->theroom;
REMPTYSCUSOR->next=NULL;
}
emptycnt++;
roomcnt++;
}
if(CUSOR->theroom.Sing==BOOKED)
{
if(RBOOKEDS==NULL)
{
RBOOKEDSCUSOR=malloc(sizeof(struct Roomp));
RBOOKEDSCUSOR->theroom=&(CUSOR->theroom);
RBOOKEDS=RBOOKEDSCUSOR;
RBOOKEDS->before=NULL;
RBOOKEDS->next=NULL;
}
else
{
RBOOKEDSCUSOR->next=malloc(sizeof(struct Roomp));
RBOOKEDSCUSOR->next->before=RBOOKEDSCUSOR;
RBOOKEDSCUSOR=RBOOKEDSCUSOR->next;
RBOOKEDSCUSOR->theroom=&(CUSOR->theroom);
RBOOKEDSCUSOR->next=NULL;
}
if(CBOOKEDS==NULL)
{
CBOOKEDSCUSOR=malloc(sizeof(struct Customers));
CBOOKEDSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
CBOOKEDS=CBOOKEDSCUSOR;
CBOOKEDS->before=NULL;
CBOOKEDS->next=NULL;
}
else
{
CBOOKEDSCUSOR->next=malloc(sizeof(struct Customers));
CBOOKEDSCUSOR->next->before=CBOOKEDSCUSOR;
CBOOKEDSCUSOR=CBOOKEDSCUSOR->next;
CBOOKEDSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
CBOOKEDSCUSOR->next=NULL;
}
if(ALLCUSTOMERS==NULL)
{
ALLCUSTOMERSCUSOR=malloc(sizeof(struct Customers));
ALLCUSTOMERSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
ALLCUSTOMERS=ALLCUSTOMERSCUSOR;
ALLCUSTOMERS->before=NULL;
ALLCUSTOMERS->next=NULL;
}
else
{
ALLCUSTOMERSCUSOR->next=malloc(sizeof(struct Customers));
ALLCUSTOMERSCUSOR->next->before=ALLCUSTOMERSCUSOR;
ALLCUSTOMERSCUSOR=ALLCUSTOMERSCUSOR->next;
ALLCUSTOMERSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
ALLCUSTOMERSCUSOR->next=NULL;
}
bookedcnt++;
roomcnt++;
customercnt++;
}
if(CUSOR->theroom.Sing==CHECKEDIN)
{
if(RCHECKEDINS==NULL)
{
RCHECKEDINSCUSOR=malloc(sizeof(struct Roomp));
RCHECKEDINSCUSOR->theroom=&CUSOR->theroom;
RCHECKEDINS=RCHECKEDINSCUSOR;
RCHECKEDINS->before=NULL;
RCHECKEDINS->next=NULL;
}
else
{
RCHECKEDINSCUSOR->next=malloc(sizeof(struct Roomp));
RCHECKEDINSCUSOR->next->before=RCHECKEDINSCUSOR;
RCHECKEDINSCUSOR=RCHECKEDINSCUSOR->next;
RCHECKEDINSCUSOR->theroom=&CUSOR->theroom;
RCHECKEDINSCUSOR->next=NULL;
}
if(CCHECKEDINS==NULL)
{
CCHECKEDINSCUSOR=malloc(sizeof(struct Customers));
CCHECKEDINSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
CCHECKEDINS=CCHECKEDINSCUSOR;
CCHECKEDINS->before=NULL;
CCHECKEDINS->next=NULL;
}
else
{
CCHECKEDINSCUSOR->next=malloc(sizeof(struct Customers));
CCHECKEDINSCUSOR->next->before=CCHECKEDINSCUSOR;
CCHECKEDINSCUSOR=CCHECKEDINSCUSOR->next;
CCHECKEDINSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
CCHECKEDINSCUSOR->next=NULL;
}
if(ALLCUSTOMERS==NULL)
{
ALLCUSTOMERSCUSOR=malloc(sizeof(struct Customers));
ALLCUSTOMERSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
ALLCUSTOMERS=ALLCUSTOMERSCUSOR;
ALLCUSTOMERS->before=NULL;
ALLCUSTOMERS->next=NULL;
}
else
{
ALLCUSTOMERSCUSOR->next=malloc(sizeof(struct Customers));
ALLCUSTOMERSCUSOR->next->before=ALLCUSTOMERSCUSOR;
ALLCUSTOMERSCUSOR=ALLCUSTOMERSCUSOR->next;
ALLCUSTOMERSCUSOR->thecustomer=&(CUSOR->theroom.Client_list);
ALLCUSTOMERSCUSOR->next=NULL;
}
checkedincnt++;
roomcnt++;
customercnt++;
}
CUSOR=CUSOR->next;
}
done=1;
}
printf("\t\t\t ======入住顾客统计======\n");
printf("\t\t==============================================\n");
printf("\t\t 姓 名 性 别 身份证号 登记时间 \n");
printf("\t\t*--------------------------------------------*\n");
CPCUSOR=CCHECKEDINS;
while(CPCUSOR!=NULL)
{
printf("\t\t %6s %2s %18s %d/%d/%d\n",CPCUSOR->thecustomer->Name,CPCUSOR->thecustomer->Sex,CPCUSOR->thecustomer->ID_card,CPCUSOR->thecustomer->year,CPCUSOR->thecustomer->month,CPCUSOR->thecustomer->day);
printf("\t\t*--------------------------------------------*\n");
CPCUSOR=CPCUSOR->next;
}
printf("\t\t 合计: %3u 个\n",checkedincnt);
printf("\t\t==============================================\n");
break;
}
case '0':
{
return;
break;
}
default:
{
printf("\n无效选择!\n");
break;
}
}
}
}
2007-07-17 21:29
mzjllh
Rank: 2
来 自:江苏扬州
等 级:论坛游民
帖 子:76
专家分:41
注 册:2007-2-8
收藏
得分:0 
void save() /*保存台账*/
{
char savepath[50]=SPACE;
char flag='x';
struct Rooms *HEAD=ROOM;
struct Rooms *CUSOR=HEAD;
FILE *SAVETO;
printf("\t\t\t ======保存当前台账======\n");
while(1)
{
if(!strcmp(SAVEPATH,DEFAULTPATH))
{
printf("\n保存到默认位置 %s 吗?(Y/N)\n",DEFAULTPATH);
flag=tolower(flag);
while(flag!='y'&&flag!='n')
{
flag=getch();
flag=tolower(flag);
if(flag==ESC)
{
printf("\n放弃保存!\n");
return;
}
}
if(flag=='y') {strcpy(savepath,DEFAULTPATH);}
}
else
{
if(!strcmp(LOADPATH,SAVEPATH))
{
printf("\n保存到装载位置 %s 吗?(Y/N)\n",LOADPATH);
while(flag!='y'&&flag!='n')
{
flag=getch();
flag=tolower(flag);
if(flag==ESC)
{
printf("\n放弃保存!\n");
return;
}
}
if(flag=='y') {strcpy(savepath,DEFAULTPATH);}
}
else
{
printf("\n保存到上次保存位置 %s 吗?(Y/N)\n",SAVEPATH);
while(flag!='y'&&flag!='n')
{
flag=getch();
flag=tolower(flag);
if(flag==ESC)
{
printf("\n放弃保存!\n");
return;
}
}
if(flag=='y') {strcpy(savepath,SAVEPATH);}
}
}
if(flag=='n')
{
printf("\n输入保存路径:");
scanf("%s",savepath);
}
flag='x';
if((SAVETO=fopen(savepath,"wb"))==NULL)
{
printf("\n文件保存失败!\n");
continue;
}
printf("\n正在保存...\n");
while(CUSOR!=NULL)
{
fwrite(&(CUSOR->theroom),sizeof(struct Hotel),1,SAVETO);
CUSOR=CUSOR->next;
}
fclose(SAVETO);
SAVED=1;
printf("\n保存成功!\n");
strcpy(SAVEPATH,savepath);
break;
}
}
char *cmdtolower(char *cmd) /*命令转换为小写*/
{
unsigned pos=0;
while(cmd[pos]!='\0')
{
cmd[pos]=tolower(cmd[pos]);
++pos;
}
return cmd;
}
void flushstdin() /*刷新输入缓冲区*/
{
char c;
while((c=getchar())!='\n'&&c!=EOF);
}
void menu() /*菜单*/
{
dispmenu();
while(1)
{
printf("\nCOMMAND:>");
scanf("%s",command);
flushstdin();
cmdtolower(command);
if(!(strcmp(command,BOOK)&&strcmp(command,"book"))) {book();continue;}
if(!(strcmp(command,UNBOOK)&&strcmp(command,"unbook"))) {unbook();continue;}
if(!(strcmp(command,CHECKIN)&&strcmp(command,"checkin"))) {checkin();continue;}
if(!(strcmp(command,CHECKOUT)&&strcmp(command,"checkout"))) {checkout();continue;}
if(!(strcmp(command,READY)&&strcmp(command,"ready"))) {ready();continue;}
if(!(strcmp(command,STATISTIC)&&strcmp(command,"statistic"))) {statistic();continue;}
if(!(strcmp(command,MENU)&&strcmp(command,"menu"))) {dispmenu();continue;}
if(!(strcmp(command,MODIFY)&&strcmp(command,"modify"))) {modify();continue;}
if(!(strcmp(command,SAVE)&&strcmp(command,"save"))) {save();continue;}
if(!(strcmp(command,ADDHOUSE)&&strcmp(command,"addhouse"))) {addhouse();continue;}
if(!(strcmp(command,LOAD)&&strcmp(command,"load"))) {load();continue;}
if(!(strcmp(command,CQUERY)&&strcmp(command,"cquery"))) {cquery();continue;}
if(!(strcmp(command,HQUERY)&&strcmp(command,"hquery"))) {hquery();continue;}
if(!(strcmp(command,REBUILD)&&strcmp(command,"rebuild"))) {rebuild();continue;}
if(!(strcmp(command,MODICOLOR)&&strcmp(command,"modicolor"))) {modicolor();continue;}
if(!(strcmp(command,CLS)&&strcmp(command,"cls"))) {cls();continue;}
if(!(strcmp(command,HELP)&&strcmp(command,"help"))) {help();continue;}
if(!(strcmp(command,EXIT)&&strcmp(command,"exit"))) {testsave();break;}
printf("Bad command!\n");
}
}
/*|------------------------|*/
/*|*********主函数*********|*/
/*|________________________|*/
int main()
{
cls();
strcpy(COLOR,strcat(BGCOLOR,FORCOLOR));
system(strcat("color ",COLOR));
menu();
return 0;
}
/*|------------------------|*/
/*|**********结束**********|*/
/*|________________________|*/
2007-07-17 21:29
mzjllh
Rank: 2
来 自:江苏扬州
等 级:论坛游民
帖 子:76
专家分:41
注 册:2007-2-8
收藏
得分:0 

妈呀,累死了,还有字数限制。

2007-07-17 21:30
Soar4139
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2007-3-31
收藏
得分:0 

我看都看晕了……佩服楼上
我转载到我自己电脑上研究研究哈,勿见怪;)


在我心中我知道,这是永恒的长跑……
2007-07-17 21:30
mzjllh
Rank: 2
来 自:江苏扬州
等 级:论坛游民
帖 子:76
专家分:41
注 册:2007-2-8
收藏
得分:0 
写了一天多,头都大了,到底不是专业的,代码不够精简。
继续学习。
2007-07-17 21:33
mzjllh
Rank: 2
来 自:江苏扬州
等 级:论坛游民
帖 子:76
专家分:41
注 册:2007-2-8
收藏
得分:0 
这里是编译好的EXE和源文件,有兴趣的看看吧。
5YfE78jk.rar (39.87 KB) C语言实习题目,自己不行了..搞不定回不了家了....


[此贴子已经被作者于2007-7-17 21:40:24编辑过]

2007-07-17 21:39
快速回复:C语言实习题目,自己不行了..搞不定回不了家了....
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.122650 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved