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();}
哈哈 懒得写注释 你好歹也缩进一下……
这种东西,谁看的懂啊
你是不是学计算机的?老师没跟你说过写程序的时候要写注释么?给十分,还写这么一大段程序,谁给你回答就是白痴!你以为程序员就该当奴隶啊!
答:#include"stdio.h" #include"math.h" main() { int i,j,k; i=2; j=0; do{ for(k=2;k<s...详情>>
答:如何面对困难 人生下来注定要同困难打交道的,或是困难吞没懦夫,或是强者征服困难。故而,"困难像弹簧,你弱它就强"的说法是可以成立的。 我们每走一步都会遇到困难,...详情>>