69,371
社区成员
发帖
与我相关
我的任务
分享
/************************************************
*函数名: vip_statistic(分类统计会员信息)
*功能:分类统计会员信息
*返回值:void(无返回值)
*************************************************/
void vip_statistic(VIP* head)
{
int num,num1; //子菜单选择
VIP *p1,*p2;
int flag; //flag是用来判断是否找到,
int c,total;
char h[12];
total=0;
p2=NULL;
while(1)
{
printf("\n**************统计子菜单*******************\n");
printf("1.统计会员人数\n");
printf("2.统计会员等级\n");
printf("3.返回主菜单\n");
printf("*******************************************\n");
fflush(stdin);
scanf("%d",&num); //选择你想要查询的方式
switch(num)
{
case 1:
while( head != p2)
{
p1 = head;
while( p1->next!= p2 )
{
if( p1->code > p1->next->code)
{
ch_swap(p1->clas,p1->next->clas);
ch_swap(p1->name,p1->next->name);
ch_swap(p1->sex,p1->next->sex);
ch_swap(p1->tel,p1->next->tel);
ch_swap(p1->birthday,p1->next->birthday);
in_swap(p1->times,p1->next->times);
total++;
}
}
p2= p1;
}
system("cls");
printf("共有会员人数%d人,详细信息如下",total);
printf("\n===编号====会员等级====姓名====性别===电话============生日=======消费次数===\n\n");
while(p1!=NULL)
{
printf(" %d %s %s %s %s %s %d",p1->code,p1->clas,p1->name,p1->sex,p1->tel,p1->birthday,p1->times);
printf("\n");
p1=p1->next;
}
break;
case 2:
{
while(1)
{
printf("\n**************会员等级选择*******************\n");
printf("1.普通会员\n");
printf("2.黄金会员\n");
printf("3.钻石会员\n");
printf("4.返回上一级\n");
printf("*******************************************\n");
fflush(stdin);
scanf("%d",&num1); //选择你想要查询的方式
switch(num1)
{
case 1:
while( head != p2)
{
p1 = head;
while( p1->next!= p2 )
{
if(strcmp(p1->clas,"普通会员")==0)
total++;
p1 = p1->next;
}
p2= p1;
}
system("cls");
printf("共有普通会员人数%d人,详细信息如下",total);
printf("\n===编号====会员等级====姓名====性别===电话============生日=======消费次数===\n\n");
while(p1!=NULL)
{
printf(" %d %s %s %s %s %s %d",p1->code,p1->clas,p1->name,p1->sex,p1->tel,p1->birthday,p1->times);
printf("\n");
p1=p1->next;
}
break;
case 2:
while( head != p2)
{
p1 = head;
while( p1->next!= p2 )
{
if(strcmp(p1->clas,"黄金会员")==0)
total++;
p1 = p1->next;
}
p2= p1;
}
system("cls");
printf("共有黄金会员人数%d人,详细信息如下",total);
printf("\n===编号====会员等级====姓名====性别===电话============生日=======消费次数===\n\n");
while(p1!=NULL)
{
printf(" %d %s %s %s %s %s %d",p1->code,p1->clas,p1->name,p1->sex,p1->tel,p1->birthday,p1->times);
printf("\n");
p1=p1->next;
}
break;
case 3:
while( head != p2)
{
p1 = head;
while( p1->next!= p2 )
{
if(strcmp(p1->clas,"钻石会员")==0)
total++;
p1 = p1->next;
}
p2= p1;
}
system("cls");
printf("共有钻石会员人数%d人,详细信息如下",total);
printf("\n===编号====会员等级====姓名====性别===电话============生日=======消费次数===\n\n");
while(p1!=NULL)
{
printf(" %d %s %s %s %s %s %d",p1->code,p1->clas,p1->name,p1->sex,p1->tel,p1->birthday,p1->times);
printf("\n");
p1=p1->next;
}
break;
case 4:return;
default:
printf("\n输入错误,按任意键返回选择菜单\n");
getch();
}
break;
}
}
case 3:return;
default :
printf("\n输入错误,按任意键返回统计菜单\n");getch();