爱问知识人 爱问教育 医院库

c语言高手帮帮忙修改一下

首页

c语言高手帮帮忙修改一下

#include<stdio.h>#include<malloc.h>#definenull0#definen2structelement{intnum;inttime;}a,leave;structlink{intnum;intnumber;structlink*next;}main(){inti,j,stime,cost,x=0;inttop=-1,top1=-1,top2=1,price=2;charmessage;structlink*head=null,*p,*q=null,*w,*m,*rear=null;structelementpark[n],parktemp[n];printf("inputinorleave/carnumber/time\n");scanf("%c%d%d",&message,& m,&a.time); (message!='E'){if(message=='A'&&top<n-1){top++;park[top].num= m;park[top].time=a.time;printf("the%dnumbercar'spositionispark:%d\n", m,top+1);}elseif(message=='A'){p=(structlink*)malloc(sizeof(structlink));if(head==null)head=p;p->num= m;p->number=top2;if(rear==null)rear=p;else{rear->next=p;rear=p;}printf("the%dnumbercar'spositionispavement:%d\n",p->num,p->number);top2++;}if(message=='D'){for(i=top;i>=0;i--)if(park[i].num== m){for(j=top;j>i;j--){top1++;p=(structlink*)malloc(sizeof(structlink));parktemp[top1]=park[j];}leave=park[i];top=i-1;stime=a.time-leave.time;cost=price*stime;printf("the%dnumbercarstoptimeis:%d\n____________costis:%d\n", m,stime,cost);for(j=top1;j>=0;j--){top++;park[top]=parktemp[j];top1=j-1;}if(head!=null){park[top].num=head->num;park[top].time=a.time;w=head;head=head->next;free(w);top++;w=head;while(w!=null){(w->number)--;top2=w->number+1;w=w->next;}}break;}if(i<0){printf("thereisno%dnumbercarinpark.\n", m);q=head;if(head->num== m){head=head->next;free(q);m=head;while(m!=null){(m->number)--;top2=m->number+1;m=m->next;}printf("the%dnumbercarhavefoundinparktempanddreaveaway.\n", m);gototoop;}else{while(q!=null){m=q;q=q->next;if(q->num== m){x=1;m=m->next;while(m!=null){(m->number)--;top2=m->number+1;m=m->next;}}}if(x==1){q=head;p=(structlink*)malloc(sizeof(structlink));rear->next=p;rear=p;rear->num=q->num;rear->number=q->number;head=head->next;free(q);while(q->number!=1){q=head;if(q->num== m){{printf("the%dnumbercarhavefoundinparktempanddreaveaway.\n", m);m=q;m=m->next;free(q);q=m;}q=q->next;head=q;}else{{p=(structlink*)malloc(sizeof(structlink));rear->next=p;rear=p;rear->num=q->num;rear->number=q->number;q=q->next;head=q;}}}}if(q==null)printf("thereno%dnumbercarinparktemp\n", m);}}}break;}printf("inputinorleave/carnumber/time\n");scanf("%c%d%d",&message,& m,&a.time);gototoop;getch();}

提交回答

全部答案

    2006-07-23 17:38:13
  • 哈哈 懒得写注释 你好歹也缩进一下……

    r***

    2006-07-23 17:38:13

  • 2006-07-22 16:39:45
  • 这种东西,谁看的懂啊

    地***

    2006-07-22 16:39:45

  • 2006-07-12 13:42:43
  • 你是不是学计算机的?老师没跟你说过写程序的时候要写注释么?给十分,还写这么一大段程序,谁给你回答就是白痴!你以为程序员就该当奴隶啊!

    蛙***

    2006-07-12 13:42:43

  • 学习帮助 相关知识

  • 教育培训
  • 教育考试

相关推荐

正在加载...
最新问答 推荐信息 热门专题 热点推荐
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200

热点检索

  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
返回
顶部
帮助 意见
反馈

确定举报此问题

举报原因(必选):