資源描述:
《高響應(yīng)比調(diào)度算法(c語言程序?qū)崿F(xiàn)).doc》由會員上傳分享,免費在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫。
1、高響應(yīng)比調(diào)度算法(c語言程序?qū)崿F(xiàn))__________________________________________________//高響應(yīng)比調(diào)度算法
#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);
}
??
}
//按到達(dá)時間排序
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;
???????????