修改了很多,目前最新版。
以下是代码(C++):
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
using namespace std;
typedef struct
{
string name;//作业名。
int RunTime;//运行时间。次关键字。
int PRI;//优先级。
int ATime;//到达时间。主关键字。
//struct iWork* next;//下个作业。
} iWork;
iWork Work[100];//输入队列。
iWork SupportWork[100];//后备队列。
iWork ReadyWork[100];//就绪队列。
iWork FinishWork[100];//完成队列。
int Number=0,Number1=0,Number2=0;
int Qian1=0,Qian2=0,Qian3=0;
int Pidao=0,N=0;
void Print(string n,int t1,int t2,int p)
{
Work[Number].name=n;
Work[Number].RunTime=t1;
Work[Number].PRI=p;
Work[Number].ATime=t2;
}
void PrintWork(int i)
{
cout<<" "<<Work[i].name
<<" "<<Work[i].ATime
<<" "<<Work[i].RunTime
<<" "<<Work[i].PRI<<endl;
}
void PrintSupportWork(int i)
{
cout<<" "<<SupportWork[i].name
<<" "<<SupportWork[i].ATime
<<" "<<SupportWork[i].RunTime
<<" "<<SupportWork[i].PRI<<endl;
}
void PrintReadyWork(int i)
{
cout<<" "<<ReadyWork[i].name
<<" "<<ReadyWork[i].ATime
<<" "<<ReadyWork[i].RunTime
<<" "<<ReadyWork[i].PRI<<endl;
}
void SortWork()
{
iWork A;
for(int i=0; i<Number-1; i++)
for(int j=0; j<Number-1-i; j++)
if(Work[j].ATime>Work[j+1].ATime)
{
A=Work[j];
Work[j]=Work[j+1];
Work[j+1]=A;
}
else if(Work[j].ATime==Wo