求大神帮忙,后面不知道怎么写了
程序代码:
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <string.h>
typedef struct build
{
char num[10];
char name[10];
char phone[10];
char sex[10];
int mon;
}build;
typedef build Datatype;
typedef struct node
{
struct build data;
struct node *next;
}ListNode,*LinkList;
void Menu(){
system("cls");
printf("\n\n\t\t*-----------------欢迎使用!---------------|\n");
printf("\t\t* |\n");
printf("\t\t* |\n");
printf("\t\t* 1. 记录 |\n");
printf("\t\t* 2. 查找 |\n");
printf("\t\t* 3. 删除 |\n");
printf("\t\t* 4. 修改 |\n");
printf("\t\t* 5. 插入 |\n");
printf("\t\t* 6. 显示 |\n");
printf("\t\t* 7. 退出 |\n");
printf("请输入值输入1-7的数字\n");
}
void CreatListL(ListNode *L)
{
system("cls");
build x;
ListNode *s,*r;
int i=1;
r=L;
printf("请输入客户号");
scanf("%s",&x.num);
printf("请输入客户姓名");
scanf("%s",&x.name);
printf("请输入客户电话");
scanf("%s",&x.phone);
printf("请输入客户性别");
scanf("%s",&x.sex);
printf("请输入客户积分");
scanf("%d",&x.mon);
while(i){
s=(ListNode*)malloc(sizeof(ListNode));
if(s==NULL)
{
printf("\n 申请空间失败!");
exit(i);
}
strcpy(s->data.num,x.num);
strcpy(s->data.name,x.name);
strcpy(s->data.phone,x.phone);
strcpy(s->data.sex,x.sex);
s->data.mon=x.mon;
r->next=s;
r=s;
printf("是否继续输入 0否/1是");
scanf("%d",&i);
if(i==1){
printf("请输入客户号");
scanf("%s",&x.num);
printf("请输入客户姓名");
scanf("%s",&x.name);
printf("请输入客户电话");
scanf("%s",&x.phone);
printf("请输入客户性别");
scanf("%s",&x.sex);
printf("请输入客户积分");
scanf("%d",&x.mon);
}
}
r->next=NULL;
}
void PrintList(ListNode *L)
{
system("cls");
printf("客户号""\t客户姓名""\t客户电话""\t客户性别""\t客户积分\n");
ListNode *p;
p=L->next;
while(p!=NULL){
printf("%-10s%-18s%-16s%-16s%-16d\n",p->data.num,p->data.name,p->data.phone,p->data.sex,p->data.mon);
p=p->next;
}
}
void FindList(ListNode *L,char num[]){
system("cls");
ListNode *p;
char i=1;
p=L->next;
printf("%s",num);
while(p!=NULL){
if(strcmp(p->data.num,num)==0){
printf("查找的客户号为%s的以下信息\n",num);
printf("客户的姓名是:%s ",p->data.name);
printf("客户的电话是%s ",p->data.phone);
printf("客户的性别为是%s ",p->data.sex);
printf("客户积分是%d ",p->data.mon);
i=0;
break;
}
p=p->next;
}
if(i==1){
printf("没找到");
}
system("pause");
}
int Length(ListNode *L){
system("cls");
int num;
ListNode *p;
p=L->next;
while(p!=NULL){
num++;
p=p->next;
}
return num;
}
void deleList(ListNode *L,int type)
{
system("cls");
ListNode *p,*q;
int j=1;
p=L;
if(type<1||type>Length(L)) {
printf("error");
exit(1);
}
while(j<type){
p=p->next;
j++;
}
q=p->next;
p->next=q->next;
free(q);
}
void AlterList(ListNode *L,char num[]){
system("cls");
ListNode *p;
build x;
printf("请输入新的客户号");
scanf("%s",x.num);
printf("请输入新的客户姓名");
scanf("%s",x.name);
printf("请输入新的客户电话");
scanf("%s",x.phone);
printf("请输入新的客户性别");
scanf("%s",&x.sex);
printf("请输入新客户积分");
scanf("%d",&x.mon);
int i=1;
p=L->next;
while(p!=NULL){
if(p->data.num,num){
strcpy(p->data.num,x.num);
strcpy(p->data.name,x.name);
strcpy(p->data.phone,x.phone);
strcpy(p->data.sex,x.sex);
p->data.mon=x.mon;
i=0;
break;
}
p=p->next;
}
if(i==1){
printf("没找到");
}
}
void AddList(ListNode *L,int type){
system("cls");
ListNode *p,*q,*s;
int j=1;
p=L;
if(type<1||type>Length(L)+1){
printf("error");
exit(1);
}
build x;
printf("请输入新的客户号");
scanf("%s",x.num);
printf("请输入新的客户姓名");
scanf("%s",x.name);
printf("请输入新的客户电话");
scanf("%s",x.phone);
printf("请输入新的客户性别");
scanf("%s",x.sex);
printf("请输入新的客户积分");
scanf("%d",&x.mon);
s=(ListNode*)malloc(sizeof(ListNode));
if(s==NULL)
{
printf("\n 申请空间失败!");
exit(1);
}
strcpy(s->data.num,x.num);
strcpy(s->data.name,x.name);
strcpy(s->data.phone,x.phone);
p->data.mon=x.mon;
while(j<=type){
q=p;
p=p->next;
j++;
}
s->next=p;
q->next=s;
printf(" ");
}
int main()
{
ListNode *L;
ListNode *p,*r;
int type;
char num[10];
int a1,a2=1;
L=(ListNode*)malloc(sizeof(ListNode));
if(L==NULL)
{
printf("\n 申请空间失败!");
exit(0);
}
while(a2){
Menu();
scanf("%d",&a1);
if(a1>0){
switch(a1)
{
case 1:
CreatListL(L);
break;
case 2:
printf("输入查找的客户号:");
scanf(" %s",&num);
FindList(L,num);
break;
case 3:
printf("输入所删除的位置:");
scanf("%d",&type);
deleList(L,type);
break;
case 4:
printf("输入修改的客户号:");
scanf("%s",&num);
AlterList(L,num);
break;
case 5:
printf("输入插入的位置:");
scanf("%d",&type);
AddList(L,type);
break;
case 6:
PrintList(L);
system("pause");
break;
case 7:
system("cls");
printf("\t\t\t按任意键确认退出程序");
break;
}
}
if(a1>6)
break;
}
return 0;
}
还需统计系统中积分最高的客户信息,及男客户的人数。但不知道怎么写了,哪位能帮下忙




