?? main.cpp
字號:
// By Jenhsun Lo (Andy)
//
// simulate a store shop problem.
// image that we have three service . But only has two lines (queue)
// 4 people go into two queue per minute. and the third service will check which line is
// the longest one.And then get one person out of that queue into the 3rd server.
#include "implement.cpp"
#define M 2 //2 Queue
#define N 4 //4 persons per minute
void main()
{
char ans;
do{
int each1=0,each2=0,each3=0,total1=0,total2=0,rest1=0,rest2=0,minute=0,times;
float average=0;
Q queues[M];
initQueue(queues); //Inital two Queues
srand(time(NULL));
printf("Please input number of minutes to simulate=>"); //Input # minutes
scanf("%d",×);
for(int j=0;j<times;j++)
{
printf("\nThe steps of putting elements into two Queues");
printf("\n----------------------------------------");
int N1=N;
bool check=false;
check=checkQueue(queues,&total1,&total2,&N1);
while(check)
{putQueue(queues,&total1,&total2,&N1);check=false;}
Calculate(&each1,&each2,&total1,&total2,&rest1,&rest2);
getOnefromLongQueue(queues,&rest1,&rest2,&each3,&total1,&total2);
get2Queue(queues,&each1,&each2,&minute);
Calculate(&each1,&each2,&total1,&total2,&rest1,&rest2);
outPutcalculate(&rest1,&rest2,&average,&minute);
Layout(&rest1,&rest2,&each1,&each2,&each3,&total1,&total2,&average);
}
printf("\n\n ('Y' or 'y' to continue)=>");
getchar();
scanf("%c",&ans);
}while(ans=='Y'||ans=='y');
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -