银行业务队列简单模拟Java程序设计_银行业务队列简单模拟

[c++]代码库#include

using namespace std;

#define MAXSIZE 1000

typedef int QElemType;

typedef struct

{

QElemType *base;

int front;

int rear;

}SqQueue;

void InitQueue(SqQueue &Q)

{

Q.base=new QElemType[MAXSIZE];

Q.front=Q.rear=0;

}

void CreateSqQueue(SqQueue &Q1,SqQueue &Q2,int sum)

{

int a;

for(int i=0;i

{

cin>>a;

if(a%2)

{

Q1.base[Q1.rear]=a;

Q1.rear=(Q1.rear+1)%MAXSIZE;

}

else

{

Q2.base[Q2.rear]=a;

Q2.rear=(Q2.rear+1)%MAXSIZE;

}

}

}

void PrintfSqQueue(SqQueue &Q1,SqQueue &Q2,SqQueue Q3,int s)

{

int a=1;

while((Q1.front!=Q1.rear)||(Q2.front!=Q2.rear))

{

if((a==1)||(a==2))

{

if(Q1.front!=Q1.rear)

{

Q3.base[Q3.rear]=Q1.base[Q1.front];

Q3.rear=(Q3.rear+1)%MAXSIZE;

Q1.front=(Q1.front+1)%MAXSIZE;

}

}

else

{

if(Q2.front!=Q2.rear)

{

Q3.base[Q3.rear]=Q2.base[Q2.front];

Q3.rear=(Q3.rear+1)%MAXSIZE;

Q2.front=(Q2.front+1)%MAXSIZE;

}

}

a++;

if(a>3)

a=1;

}

cout<

Q3.front=(Q3.front+1)%MAXSIZE;

for(int i=0;i

{

cout<

Q3.front=(Q3.front+1)%MAXSIZE;

}

}

int main ()

{

int sum;

SqQueue Q1,Q2,Q3;

InitQueue(Q1);

InitQueue(Q2);

InitQueue(Q3);

cin>>sum;

if(sum)

{

CreateSqQueue(Q1,Q2,sum);

PrintfSqQueue(Q1,Q2,Q3,sum);

}

else

cout<

return 0;

}

694748ed64b9390909c0d88230893790.png

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值