时间片轮转算法(c++版)资料.docVIP

  • 1
  • 0
  • 约5.74千字
  • 约 6页
  • 2019-07-05 发布于湖北
  • 举报
时间片轮转算法(c版)资料

#includeiostream.h #includestdlib.h #include?conio.h const?int?QueueNum=10; const?int?QueuePre=-1; const?int?ERROR=0; const?int?OK=1; const?int?TimePiece=1; typedef?int?ElemType; ?//head?define.................... /*************************************************************/ ?class?Queue_c ?{ ?ElemType?Q[QueueNum]; ?int?front,rear; ?public: ?//basic?information?of?the?class?Queue_c: ?Queue_c(); ?int?qFull(); ?int?qEmpty(); ?int?qEnQueue(ElemType?e); ?ElemType?qDeQueue(); ?int?qGetNumber(); ?int?qGetElem(int); ?int?qShowQueue(); //other?functions: ElemType?qGetFrontElem(){if(qEmpty()){coutERROR!endl;return?ERROR;}return?Q[front];} //int?qGetFront(){if(qEmpty()){coutERROR!endl;return?ERROR;}return?front;} //ElemType?qGetRearElem(){if(qEmpty()){coutERROR!endl;return?ERROR;}return?Q[(rear-1+QueueNum)%QueueNum];} //int?qGetRear(){if(qEmpty()){coutERROR!endl;return?ERROR;}return?(rear-1+QueueNum)%QueueNum;} //int?qShowAll(); ?int?qDec() ?{ ?if(qEmpty()){coutERROR!endl;return?ERROR;}//endif ?Q[front]-=TimePiece; ?return?OK; ?} ?//int?qXChange(int); ?}; //==================Define?of?Class?Queue_c===================================== //============================================================================== ?class?Work_c ?{ Queue_c?buf; ?public: ?int?wCPU(); //?ElemType?wScan(int?t); ?int?wMakeP(); ?int?wShowBUF(){return?buf.qShowQueue();} ?int?wInBUF(int?i){return?buf.qEnQueue(i);} ?}; //==================Define?of?Class?Work_c===================================== //============================================================================== /*******************************==main==**************************************************** ********************************==proc==***************************************************/ ?void?main() ?{ ?Work_c?w; ?int?i; ?//w.wInBUF(5); ?//?w.wInBUF(3); ?//?w.wInBUF(1); ?clrscr(); ?char?flag=y; ?for(i=0;i10;i++) ?{ ?//w.buf.qShowQueue(); ?w.wMakeP();

文档评论(0)

1亿VIP精品文档

相关文档