process

//时间轮转最多 轮转
#include<iostream>
#include<queue>
using namespace std;
struct node
{
    friend bool operator< (node n1, node n2)
    {
        if(n1.t1<n2.t1)
   return false;
  if(n1.t1==n2.t1)
  {
   if(n1.t2<n2.t2)
    return true;
   if(n1.t2>n2.t2)
    return false;
  }
  return true;
    }
    int t1;//做业的到达时间
    int t2;//做业的运行时间
 int p;//进程的优先级
 char name[10];
};
struct Process//进程结构体
{
 char name[10];
 int t;//运行时间
 int p;//进程优先级
 bool s;//进程的状态
 Process *next;
};
int clock;
priority_queue<node> q;
void creat_work()//做业随机产生随机个数的做业
{
 int x=(rand()%10);
 while(x--)
 {
  clock=(clock+1)%1000;
  node work;node

  work.name[0]=(rand()%128);
  work.name[1]=(rand()%128);
  work.name[2]=(rand()%128);
  work.name[3]=(rand()%128);ios

  work.t1=(rand()%1000);
  work.t2=(rand()%1000);
  work.p=(rand()%1000);
  clock+=3;
  clock%=1000;
  q.push(work);
 }
}
void creat_process()
{spa

 

}
int main()
{
    creat_work();//产生做业
 clock=0;
 creat_process();//产生进程;
 进程


 return 0;it

}io

相关文章
相关标签/搜索