正文描述:《高响应比调度算法(c语言程序实现).doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、高响应比调度算法(c语言程序实现)__________________________________________________//高响应比调度算法
#include
#include
structzgxyb{
charname[10];
floatarrivetime;
floatservicetime;
floatstarttime;
floatfinishtime;
floatzztime;
floatdqzztime;
};
structzgxyba[100];
voidinput(structzg
2、xyb*p,intN)
{inti;
printf("intputtheprocess'sname&arrivetime&servicetime:forexmple:a0100");
for(i=0;i<=N-1;i++)
{
printf("inputthe%dthprocess's____________________________________________________________________________________________________information:",i+1);
scanf("%s
3、%f%f",&p[i].name,&p[i].arrivetime,&p[i].servicetime);
}
}voidPrint(structzgxyb*p,floatarrivetime,floatservicetime,floatstarttime,floatfinishtime,floatzztime,floatdqzztime,intN)
{intk; printf("runorder:");
printf("%s",p[0].name);
for(k=1;k%s",p[k].name
4、);
}
printf("theprocess'sinformation:");
printf("nametarrivetservicetstarttfinishtzztdqzz");
for(k=0;k<=N-1;k++)
{____________________________________________________________________________________________________printf("%st%-.2ft%-.2ft%-.2ft%-.2
5、ft%-.2ft%-.2ft",p[k].name,p[k].arrivetime,p[k].servicetime,p[k].starttime,p[k].finishtime,p[k].zztime,p[k].dqzztime);
}
}
//按到达时间排序
voidsort(structzgxyb*p,intN)
{
inti,j;
for(i=0;i<=N-1;i++)
for(j=0;j<=i;j++)
if(p[i].arrivetime
6、 {
structzgxybtemp;
temp=p[i];
p[i]=p[j];
p[j]=temp;
}
}//yunxingjieduan
voiddeal(structzgxyb*p,floatarrivetime,floatservicetime,floatstarttime,floatfinishtime,floatzztime,floatdqzztime,intN)
7、
{int____________________________________________________________________________________________________k;
for(k=0;k<=N-1;k++)
{
if(k==0)
{
p[k].starttime=p[k].arrivetime;
p[k].finishtime=p[k].arrivetime+p[k].servicetime;} else
8、 {
p[k].starttime=p[k-1].finishtime;
显示全部收起