100分求助 最高响应比算法

wosuiniqunbai 2009-01-07 12:46:07
自己写了个结果算法行不通,还涉及到动态内存分配,不懂,没成功,俺是菜鸟,高手用c++写个,俺参考下,谢谢!
...全文
195 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
xiaoyisnail 2009-01-07
  • 打赏
  • 举报
回复
帮顶
wosuiniqunbai 2009-01-07
  • 打赏
  • 举报
回复
哦。。。
就是关于作业调度的,最高响应比算法
xuruichen 2009-01-07
  • 打赏
  • 举报
回复
要求写的清楚点吗,太模糊了。
wosuiniqunbai 2009-01-07
  • 打赏
  • 举报
回复
在线等啊
太乙 2009-01-07
  • 打赏
  • 举报
回复
up~~
china_west 2009-01-07
  • 打赏
  • 举报
回复
什么题目?
就呆在云上 2009-01-07
  • 打赏
  • 举报
回复

把自己的代码贴出来
哈哈
shilei_815 2009-01-07
  • 打赏
  • 举报
回复
好用楼主别忘了给分啊@-@
shilei_815 2009-01-07
  • 打赏
  • 举报
回复
从别人那里找的,希望能帮上你的忙@-@

#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;
else
t->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();
}

帅得不敢出门 2009-01-07
  • 打赏
  • 举报
回复
把你的算法贴出来
xuruichen 2009-01-07
  • 打赏
  • 举报
回复
只能顶一下,不懂啊。

64,637

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧