怎么调试都过不去,哪位高手指导一下。谢谢
#include<stdio.h>#include<string.h>
#include<malloc.h>
#define LEN sizeof(struct car)
static int sum,s;
struct date
{
int y;
int m;
int d;
};
struct car
{
char a[10];
char b[10];
int money;
char c[10];
date time;
struct car *next;
};
struct car *tx(struct car * p);
struct car *creat();
void cx(struct car *p);
void print(struct car *p);
int *hz(struct car *p);
int *tj(struct car *p);
struct car *jr(struct car *p);
void main()
{
struct car *p,*p1;
int n,*k;
char a;
printf("shu ru yao pai dui de che de xin xi:che ming,pai hao\n");
p=creat();
printf("tongxing,tongji,huizong,chaxun,xianshi,tuichu\n");
printf("shu ru yao jin xing de cao zuo(1--6)\n");
scanf("%d",&n);
do
{
if(n==1)
{
printf("tong xing\n");
p1=tx(p);
p=p1;
}
else if(n==2)
{
printf("tong ji\n");
k=tj(p);
printf("gong you%dliang tong guo",*k);
}
else if(n==3)
{
printf("hui zong\n");
k=hz(p);
printf("zong gong %d yuan",*k);
}
else if(n==4)
{
printf("cha xun\n");
cx(p);
}
else if(n==5)
{
printf("xian shi\n");
print(p);
}
else if(n==6)
break;
else
{
printf("shu ru you wu,chong xin shu ru\n");
scanf("%d",&n);
}
printf("shi fou ji xu Y/N\n");
scanf("%s",&a);
if(a=='Y'||a=='y')
{
printf("shu ru yao jin xing d cao zuo(1--6)\n");
scanf("%d",&n);
}
else n=0;
}while(n);
}
struct car *creat()
{
struct car *head,*p1,*p2;
int m;
m=0;
p1=(struct car *)malloc(LEN);
p2=p1;
scanf("%s%s",p1->a,p1->b);
head=NULL;
while(*(p1->b)!='0')
{
m++;
if(m==1)
head=p1;
else
p2->next=p1;
p2=p1;
p1=(struct car *)malloc(LEN);
scanf("%s%s",p1->a,p1->b);
}
delete p1;
p2->next=NULL;
return head;
}
void cx(struct car *p)
{
struct car *p0,p1,p2;
int n;
p0=p;
printf("yi duan shi jian cha xun,dan cha mou liang che\n");
printf("shu ru yao jin xing de cao zuo(1--2)\n");
scanf("%d",&n);
if(n==1)
{
printf("yi duan shi jian cha xun,shu ru shi jian duan\n");
scanf("%d%d%d%d%d%d",&p1.time.y,&p1.time.m,&p1.time.d,&p2.time.y,&p2.time.m,&p2.time.d);
printf("shijian,cheming,paihao,jine\n");
while(p0)
{
if((*p0).time.y>=p1.time.y&&(*p0).time.y<=p2.time.y)
{
if((*p0).time.y==p1.time.y||(*p0).time.y==p2.time.y)
{
if((*p0).time.m>=p1.time.m&&(*p0).time.m<=p1.time.m)
{
if((*p0).time.m==p1.time.m||(*p0).time.m==p2.time.m)
{
if((*p0).time.d>=p1.time.d&&(*p0).time.d<=p2.time.d)
{
if(strcmp(p0->c,"pass")==0)
{
printf("%dnian%dyue%dri\t%s\t%s\t%d\t%s\n",p1.time.y,p1.time.m,p1.time.d,p0->a,p0->b,p0->money,p0->c);
s++;
}
}
}
else
{
if(strcmp(p0->c,"pass")==0)
{
printf("%dnian%dyue%dri\t%s\t%s\t%d\t%s\n",p1.time.y,p1.time.m,p1.time.d,p0->a,p0->b,p0->money,p0->c);
s++;
}
}
}
}
else
{
if(strcmp(p0->c,"pass")==0)
{
printf("%dnian%dyue%dri\t%s\t%s\t%d\t%s\n",p1.time.y,p1.time.m,p1.time.d,p0->a,p0->b,p0->money,p0->c);
s++;
}
}
}
p0=p0->next;
}
if(s==0)
printf("wu che tong guo\n");
}
else if(n==2)
{
printf("dan cha mou liang che,shu ru che hao\n");
scanf("%s",p1.b);
while(p0)
{
if(strcmp(p0->b,p1.b)==0)
{
if(strcmp(p0->c,"pass")==0)
{
printf("shijian,cheming,paihao,jine\n");
printf("%dnian%dyue%dri\t%s\t%s\t%d\t%s",p1.time.y,p1.time.m,p1.time.d,p0->a,p0->b,p0->money,p0->c); break;
}
else
{
printf("no pass\n");
break;
}
}
p0=p0->next;
}
if(p0==NULL)
printf("the car didn't exit\n");
}
else
printf("the data is error\n");
}
struct car *tx(struct car * p)
{
struct car *p0,*head,p1,*p2;
p0=p;
head=p;
printf("shu ru yao tong xing de che hao\n");
scanf("%s",p1.b);
while(p0)
{
if(strcmp(p0->b,p1.b)==0)
{
printf("jiao na jin e shi jian\n");
scanf("%d%d%d%d",&p1.money,&p1.time.y,&p1.time.m,&p1.time.d);
strcpy(p0->c,"pass");
p0->money=p1.money;
(*p0).time.y=p1.time.y;
(*p0).time.m=p1.time.m;
(*p0).time.d=p1.time.d;
break;
}
p0=p0->next;
}
if(p0==NULL)
{
printf("you xin che jia ru");
p2=jr(p);
head=p2;
}
return head;
}
int *tj(struct car *p)
{
struct car *p0,p1,p2;
p0=p;
s=0;
printf("yi duan shi jian cha xun,shu ru shi jian duan\n");
scanf("%d%d%d%d%d%d",&p1.time.y,&p1.time.m,&p1.time.d,&p2.time.y,&p2.time.m,&p2.time.d);
while(p0)
{
if((*p0).time.y>=p1.time.y&&(*p0).time.y<=p2.time.y)
{
if((*p0).time.y==p1.time.y||(*p0).time.y==p2.time.y)
{
if((*p0).time.m>=p1.time.m&&(*p0).time.m<=p1.time.m)
{
if((*p0).time.m==p1.time.m||(*p0).time.m==p2.time.m)
{
if((*p0).time.d>=p1.time.d&&(*p0).time.d<=p2.time.d)
{
if(strcmp(p0->c,"pass")==0)
{
printf("%dnian%dyue%dri\t%s\t%s\t%d\t%s\n",p1.time.y,p1.time.m,p1.time.d,p0->a,p0->b,p0->money,p0->c);
s++;
}
}
}
else
{
if(strcmp(p0->c,"pass")==0)
{
printf("%dyear%dmonth%dday\t%s\t%s\t%d\t%s\n",p1.time.y,p1.time.m,p1.time.d,p0->a,p0->b,p0->money,p0->c);
s++;
}
}
}
}
else
{
if(strcmp(p0->c,"pass")==0)
{
printf("%dyear%dmonth%dday\t%s\t%s\t%d\t%s\n",p1.time.y,p1.time.m,p1.time.d,p0->a,p0->b,p0->money,p0->c);
s++;
}
}
}
p0=p0->next;
}
if(s==0)
printf("no car pass\n");
return &s;
}
int *hz(struct car *p)
{
struct car *p0,p1,p2;
p0=p;
sum=0;
printf("yi duan shi jian cha xun,shu ru shi jian duan\n");
scanf("%d%d%d%d%d%d",&p1.time.y,&p1.time.m,&p1.time.d,&p2.time.y,&p2.time.m,&p2.time.d);
while(p0)
{
if((*p0).time.y>=p1.time.y&&(*p0).time.y<=p2.time.y)
{
if((*p0).time.y==p1.time.y||(*p0).time.y==p2.time.y)
{
if((*p0).time.m>=p1.time.m&&(*p0).time.m<=p1.time.m)
{
if((*p0).time.m==p1.time.m||(*p0).time.m==p2.time.m)
{
if((*p0).time.d>=p1.time.d&&(*p0).time.d<=p2.time.d)
{
if(strcmp(p0->c,"pass")==0)
{
printf("%dnian%dyue%dri\t%s\t%s\t%d\t%s\n",p1.time.y,p1.time.m,p1.time.d,p0->a,p0->b,p0->money,p0->c);
sum+=p0->money;
}
}
}
else
{
if(strcmp(p0->c,"pass")==0)
{
printf("%dnian%dyue%dri\t%s\t%s\t%d\t%s\n",p1.time.y,p1.time.m,p1.time.d,p0->a,p0->b,p0->money,p0->c);
sum+=p0->money;
}
}
}
}
else
{
if(strcmp(p0->c,"pass")==0)
{
printf("%dnian%dyue%dri\t%s\t%s\t%d\t%s\n",p1.time.y,p1.time.m,p1.time.d,p0->a,p0->b,p0->money,p0->c);
sum+=p0->money;
}
}
}
p0=p0->next;
}
if(sum==0)
printf("wu che tong guo\n");
return ∑
}
void print (struct car *p)
{
struct car *p0;
p0=p;
while(p0)
{
if(strcmp(p0->c,"pass")==0)
printf("%s\t%s\t%d\t%dnian%dyue%dri\n",p0->a,p0->b,p0->money,(*p0).time.y,(*p0).time.m,(*p0).time.d);
else
printf("%s\t%s\t not pass\n",p0->a,p0->b);
p0=p0->next;
}
}
struct car *jr(struct car *p)
{
struct car *p0,*p1,*head,*p2;
p0=p;
head=p0;
printf("shu ru che ming he pai hao\n");
p2=creat();
while(p0)
{
p1=p0;
p0=p0->next;
}
p1->next=p2;
return head;
}