你牛B 什么啊 ?!?!大爷我编出来了!!没用别人帮忙!!你可以鄙视我,可你照样被千千万万的人鄙视着!!#include"stdlib.h"#include"string.h"#include"iostream.h"typedef struct cj{char name[6];int length;int printer;int tape;int runtime;int waittime;struct cj *next;}cj;cj *head;int tape,printer;long memory;
void shedule(){float xk,k;cj *p,*q,*s,*t;do{p=head;q=s=NULL;k=0;while(p!=NULL){if(p->length<=memory&&p->tape<=tape&&p->printer<=printer){xk=(float)(p->waittime)/p->runtime;if(q==NULL||xk>k){k=xk;q=p;t=s;}}s=p;p=p->next;}if(q!=NULL){if(t==NULL)head=head->next;elset->next=q->next;memory=memory-q->length;tape=tape-q->tape;printer=printer-q->printer;cout<<"选中作业的作业名:"<<q->name<<"\n";}}while(q!=NULL);}
void main(){int size,tcount,pcount,wtime,rtime;char name[6];cj *p;memory=65536;printer=2;tape=4;head=NULL;cout<<"输入作业相关数据(以作业大小为负数停止输入):\n";cout<<"输入作业名、作业大小、磁带机数、打印机数、等待时间、估计执行时间\n";cin>>name>>size>>tcount>>pcount>>wtime>>rtime;while(size!=-1){p=(cj*)malloc(sizeof(cj));strcpy(p->name,name);p->length=size;p->printer=pcount;p->tape=tcount;p->runtime=rtime;p->waittime=wtime;p->next=head;head=p;cout<<"输入作业名、作业大小、磁带机数、打印机数、等待时间、估计执行时间\n";cin>>name>>size>>tcount>>pcount>>wtime>>rtime;}shedule();}