| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 943 人关注过本帖
标题:模拟高速路口收费系统 用C语言编 向高手请教
取消只看楼主 加入收藏
个人专属21
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2011-6-26
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:2 
模拟高速路口收费系统 用C语言编 向高手请教
6、编写程序模拟高速路口收费程序,只允许在队尾排队不允许插队。记录的汽车信息可简可繁例如:时间,车号,金额等。实现的功能包括:
(1)    汽车排队即输入并显示多辆汽车的信息;
(2)    查询(至少提供按汽车车号查询或按汽车通过时间查询);
(3)    统计(至少提供按通行时间通过的车辆);
(4)    汇总(至少提供指定一天或某一时间段内收费金额);
(5)    输出一天通过的车辆信息。
程序所显示的菜单内容如下:
请选择下面的一个项目:
1    排队
2    通行
3    查询
4    统计
5    汇总
6    显示
7    退出
搜索更多相关主题的帖子: C语言 
2011-06-26 10:30
个人专属21
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2011-6-26
收藏
得分:0 
改了半天依然不对。。。无法运行。。。
#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;
}
2011-06-27 20:04
个人专属21
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2011-6-26
收藏
得分:0 
用turbo c运行不了啊....我们现在用的是turbo c...
2011-06-28 18:27
快速回复:模拟高速路口收费系统 用C语言编 向高手请教
数据加载中...
 
   



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

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