#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream.h>
typedef struct node
{
char name[10];
int prio;
int round;
int cputime;
int needtime;
int count;
char state;
struct node *next;
}PCB;
PCB *finish,*ready,*tail,*run;
int N;
void firstin()
{
run=ready;
run->state='R';
ready=ready->next;
}
//输出标题函数
void prt1(char a)
{
if(toupper(a)=='P')
cout<<" "<<endl;
cout<<"进程名 占用CPU时间 到完成还要的时间 轮转时间片 状态"<<endl;
}
//进程PCB输出
void prt2(char a,PCB *q)
{
if(toupper(a)=='P')
cout<<q->name<<" "<<q->cputime<<" "<<q->needtime<<" "<<
q->round<<" "<<q->state<<endl;
}
//输出函数
void prt(char algo)
{
PCB *p;
prt1(algo);
if(run!=NULL)
prt2(algo,run);
p=ready;
while(p!=NULL)
{
prt2(algo,p);
p=p->next;
}
p=finish;
while(p!=NULL)
{
prt2(algo,p);
p=p->next;
}