You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
84 lines
1.2 KiB
84 lines
1.2 KiB
typedef struct{
|
|
int *base;
|
|
int front;
|
|
int rear;
|
|
}sq;
|
|
|
|
void initqueue(sq &f){
|
|
f.base=new char[11];
|
|
if(!f.base) exit();
|
|
f.front=f.rear=0;
|
|
return;
|
|
}
|
|
|
|
void initqueuem(sq &f){
|
|
f.base=new char[100];
|
|
if(!f.base) exit();
|
|
f.front=f.rear=0;
|
|
return;
|
|
}
|
|
|
|
void enqueue(sq &f,int e){
|
|
if((f.rear+1)%11==f.front)return;
|
|
f.base[f.rear]=e;
|
|
f.rear=(f.rear+1)%11;
|
|
return;
|
|
}
|
|
|
|
void dequeue(sq &f,int &e){
|
|
if(f.rear==f.front)return;
|
|
e=f.base[f.front];
|
|
f.front=(f.front+1)%11;
|
|
return;
|
|
}
|
|
|
|
void hcenqueue(sq &t,int hc,int y){
|
|
int i;
|
|
if(hc>100)print("data error");
|
|
else{
|
|
for(i=0;i<hc;i++){
|
|
enqueue(t,y);
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
|
|
void kcenqueue(sq &t,int kc,int x){
|
|
int i;
|
|
if(kc>100)print("data error");
|
|
else{
|
|
for(i=0;i<kc;i++){
|
|
enqueue(t,x);
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
|
|
bool a(sq &t){
|
|
if(t.rear==t.front)
|
|
return True;
|
|
else return False;
|
|
}
|
|
|
|
void bl(sq t,int j){
|
|
int ch,i;
|
|
printf("第%d辆的运船顺序是:\n",j);
|
|
for(i=0;i<10;i++){
|
|
{dequeue(f,ch);print("%3d",ch);}
|
|
}
|
|
print(\n);
|
|
}
|
|
void main(){
|
|
int bus=0,truck=0,total=0,i,k,j,x=1,y=2,e;
|
|
sq f,b,t;
|
|
initqueue(f);initqueuem(b);initqueuem(t);
|
|
printf("请输入客车的数量");
|
|
scanf("%d",&bus);
|
|
rintf("请输入货车的数量");
|
|
scanf("%d",&truck);
|
|
k=(bus+truck)/10+1;
|
|
for(j=0;j<k;j++) {
|
|
|
|
}
|
|
}
|