帮忙,急救!

请各位把我的这个程序改一下,改成能够运行

设计题目是电梯模拟(或者帮忙传个C语言的代码给我)

#include<stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#define datatype  int
#define MaxSize   9
#define ok 1
typedef struct //队列,结构体定义
{
    int data;
 int num;
 int curtime;
    int front; 
    int rear; 
    int count;
 typedef struct *next;
}SeQueue;
datatype Mg[MaxSize];
void  Init_Queue(SeQueue *q)//初始化队列Q
{
   q->count=0;//定义初始计数器值
   q->front=0;//定义初始队头指针下标值
   q->rear=0;//定义初始队尾指针下标值
}

int Empty_Queue(SeQueue *q)
{
   if(q->count!=0)
    return 1;
   else
    return 0;
}
int In_Queue(SeQueue *q,datatype x,datatype y,datatype z)//入队列
{
 int i=1;
  if(q->count>0 && q->rear==q->front)
  {
   printf("队列已满无法插入!/n");
   return 0; 
  }
  else
  {
   q->data=x;
   while(i<=y)
   {
    q->num=i;
    i++;
   }
   q->curtime=z;
      q->count++;
      return 1;
  }
}
int Out_Queue(SeQueue *q, int *x,int *y,datatype *z)//出队列
{
    if(q->count=0)
 {
  printf("队列已空无数据元素出队列!/n");
  return 0; 
 }
 else
 {
  *x=q->data;
  *y=q->num;
  *z=q->curtime;
  q->count--;
  return q->count;
 }
}
datatype Front_Queue(SeQueue *q,datatype x)//取队列元素
{
  if(q->count=0)
 {
  printf("队列已空无数据元素可取!/n");
  return 0; 
 }
  else
  {
   x=q->data;
         return x;
  }
}
int up(int floor,int Mg[MaxSize],int Rg[MaxSize])//上楼
{
 int time=0,time2;
 int c,b=0,d;
 while(floor<=5)
  {
      c=Mg[b];
   d=Rg[b];
   if(d>c)
     printf("电梯正在往上运行,乘客请等待");
     else if(c!=floor&&d!=floor)
         printf("电梯正在运行");
   else if(c==floor&&d!=floor)
   {
   printf("目的楼层已经到了,乘客请出电梯");
   time=time+20*(d-c);
   printf("/t/t%d 时刻,电梯到达第%d层/n",time,floor);
   time2=time2+50;
   }
   else if(c!=floor&&d==floor)
   {
     printf("楼层已到,请乘客入电梯");
    time2=time2+50;
     }
     else
     {   
       printf("目的楼层已经到了,相关乘客请出电梯");
                time=20*(d-c);
       printf("/t/t%d 时刻,电梯到达第%d层/n",time,floor);
    time2=time2+50;
       printf("楼层已到,相关乘客请入电梯");
    }
  b++;
     floor++;
  time=time2;
 }
 return b;
}
void down(int b,int Mg[MaxSize],int Rg[MaxSize])//下楼
{
  int time,time2,floor=5,c,d;
  while(floor>=1)
  {
      c=Mg[b];
   d=Rg[b];
   if(d<c)
     printf("电梯正在往下运行,乘客请等待");
     else if(c!=floor&&d!=floor)
         printf("电梯正在运行");
   else if(c==floor&&d!=floor)
   {
   printf("目的楼层已经到了,乘客请出电梯");
   time=time+20*(d-c);
   printf("/t/t%d 时刻,电梯到达第%d层/n",time,floor);
   time2=time2+50;
   }
   else if(c!=floor&&d==floor)
   {
     printf("楼层已到,请乘客入电梯");
    time2=time2+50;
     }
     else
     {   
       printf("目的楼层已经到了,相关乘客请出电梯");
                time=20*(d-c);
       printf("/t/t%d 时刻,电梯到达第%d层/n",time,floor);
    time2=time2+50;
       printf("楼层已到,相关乘客请入电梯");
    }
  b++;
     floor--;
  time=time2;
 }
}
void paixu(datatype Mg[],int n)
{
 int i,j,temp;
    for(i=1;i<=n;i++)
  for(j=i+1;j<=n;j++)
  {
   if(Mg[i]>Mg[j])
   {
    temp=Mg[i];
    Mg[j]=temp;
    Mg[i]=Mg[j];
   }
  }
}
int main()
{
 int *p,*t,*r;
 int i,x,y,z,flag=1,m,n,c,b,k=1;
 int j=1,floor=1;
 int Mg[MaxSize],Rg[MaxSize];//记录到达的楼层信息
 SeQueue from,go;
 int time1;
 int state=1;
 Init_Queue(&from);
 Init_Queue(&go);
 printf("/t/t *****************************************************/n");
 printf("/t/t *                                                   */n");
 printf("/t/t *                 电梯模拟程序                      */n");
 printf("/t/t *                                                   */n");
  printf("/t/t *****************************************************/n");
 printf("电梯在本垒层候命");
 printf("此电梯的层数为5");
 while(flag)
 {
  printf("是否有人要进入此电梯,是的输入1,否则输入0");
  scanf("%",&i);
  if(i==0)
  {
     flag=0;
     printf("over");
     printf("谢谢光顾");
  }
  else
 {
  printf("请输入你所在的楼层");
  scanf("%d",&x);
  printf("此人向电梯发送的时间");
  scanf("%d",&z);
  printf("请输入你的最大容忍时间是");
  scanf("%d",&time1);
  In_Queue(&from,&x,&y,&z);
  printf("请输入你要到达的楼层");
  scanf("%d",&n);
  In_Queue(&go,&n,&y,&z);
  Mg[j-1]=n;
  Rg[j-1]=x;      
  j++;
  y++;
  }
  k=j;
  from=from->next;
  go=go->next;
  }
  paixu(Mg,y);
  paixu(Rg,y);
  while(k!=0)
  {
     Out_Queue(go,p,t,r);
  printf("第%d名乘客到%d层",*p,*t);
  k=Out_Queue(go,p,t,r);
  }
  while(state)
  {
     printf("如果你想结束电梯的运行请输入0,否则输入1");
  scanf("%d",&m);
  state=m;
  printf("电梯准备运行");
  up(floor,Mg,Rg);
  b=up(floor,Mg,Rg);
     down(b,Mg,Rg);
  }
printf("欢迎乘坐该电梯");
return ok;
}
 错误是:

-------------------Configuration: 电梯模拟4 - Win32 Debug--------------------
Compiling...
电梯模拟4.cpp
C:/Documents and Settings/01.01-0DFBDBB6E43B/桌面/电梯模拟4.cpp(207) : error C2664: 'In_Queue' : cannot convert parameter 2 from 'int *' to 'int'
        This conversion requires a reinterpret_cast, a C-style cast or function-style cast
C:/Documents and Settings/01.01-0DFBDBB6E43B/桌面/电梯模拟4.cpp(210) : error C2664: 'In_Queue' : cannot convert parameter 2 from 'int *' to 'int'
        This conversion requires a reinterpret_cast, a C-style cast or function-style cast
C:/Documents and Settings/01.01-0DFBDBB6E43B/桌面/电梯模拟4.cpp(217) : error C2819: type 'SeQueue' does not have an overloaded member 'operator ->'
        C:/Documents and Settings/01.01-0DFBDBB6E43B/桌面/电梯模拟4.cpp(9) : see declaration of 'SeQueue'
C:/Documents and Settings/01.01-0DFBDBB6E43B/桌面/电梯模拟4.cpp(217) : error C2227: left of '->next' must point to class/struct/union
C:/Documents and Settings/01.01-0DFBDBB6E43B/桌面/电梯模拟4.cpp(218) : error C2819: type 'SeQueue' does not have an overloaded member 'operator ->'
        C:/Documents and Settings/01.01-0DFBDBB6E43B/桌面/电梯模拟4.cpp(9) : see declaration of 'SeQueue'
C:/Documents and Settings/01.01-0DFBDBB6E43B/桌面/电梯模拟4.cpp(218) : error C2227: left of '->next' must point to class/struct/union
C:/Documents and Settings/01.01-0DFBDBB6E43B/桌面/电梯模拟4.cpp(224) : error C2664: 'Out_Queue' : cannot convert parameter 1 from 'SeQueue' to 'SeQueue *'
        No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
C:/Documents and Settings/01.01-0DFBDBB6E43B/桌面/电梯模拟4.cpp(226) : error C2664: 'Out_Queue' : cannot convert parameter 1 from 'SeQueue' to 'SeQueue *'
        No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
执行 cl.exe 时出错.

电梯模拟4.obj - 1 error(s), 0 warning(s)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值