| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 469 人关注过本帖
标题:怎么调试都过不去,哪位高手指导一下。谢谢
只看楼主 加入收藏
hg3236675
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2011-6-28
结帖率:0
收藏
已结贴  问题点数:20 回复次数:2 
怎么调试都过不去,哪位高手指导一下。谢谢
#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 &sum;
}
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;
}

搜索更多相关主题的帖子: include money 
2011-06-28 16:55
kami_dante
Rank: 2
等 级:论坛游民
帖 子:37
专家分:93
注 册:2010-12-29
收藏
得分:10 
//   
2011-06-29 00:03
ppfly
Rank: 10Rank: 10Rank: 10
等 级:青峰侠
帖 子:297
专家分:1956
注 册:2009-5-17
收藏
得分:10 
可以编译运行。

********多贴代码,少说空话*******
2011-06-29 00:44
快速回复:怎么调试都过不去,哪位高手指导一下。谢谢
数据加载中...
 
   



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

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