先来先服务调度算法(first come first service)是操作系统调度进程的简单算法。假设有若干个进程在就绪队列中等待执行,则优先执行最早进入队列的进程,执行完毕后,将进程弹出队列。
现在,需要你来模拟FCFS算法。
#include<bits/stdc++.h>
using namespace std;
char que[100];
int head,tail,mod;
bool isFull()
{
if(____(1)_____)
{
printf("is full\n");
return true;
}
else
return false;
}
bool isEmpty()
{
if(_____(2)____)
{
printf("is empty\n");
return true;
}
else
return false;
}
void push(char pro)
{
if(!isFull())
{
______(3)_____;
que[head]=pro;
}
}
void pop()
{
if(!isEmpty())
{
tail=(tail+1)%mod;
printf("%c\n",____(4)_____);
}
}
int main()
{
int n,opt;
char pro;
scanf("%d%d",&n,&mod);
head=0;
tail=0;
while(n--)
{
scanf("%d",&opt);
if(opt==1)
{
scanf(" %c",&pro);
push(pro);
}
else if(opt==2)
pop();
}
}