开发工具:
文件大小: 2kb
下载次数: 0
上传时间: 2010-03-08
详细说明: #include "stdlib.h" typedef struct jcb { char name[4]; int length; int printer; int tape; int runtime; int waittime; struct jcb *next; }JCB; JCB *head; int tape,printer; long memory; shedule( ) { float w,k; JCB *p,*q,*s,*t; do { p=head; s=NULL; q=NULL; k=0; while(p!=NULL) { if(p->length<=memory&&p->tape<=tape&&p->printer<=printer) { w=(float)(p->waittime)/p->runtime; if(q==NULL||w>k) { k=w; 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; printf("Selects:%s\n",q->name); } }while(q!=NULL); } inital() { int w,k; JCB *p,*q,*s,*t; do { p=head; s=NULL; q=NULL; k=0; while(p!=NULL) { if(p->length<=memory&&p->tape<=tape&&p->printer<=printer) { w=1/(p->runtime); if(q==NULL||w>k) { k=w; 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; printf("Selects:%s\n",q->name); } }while(q!=NULL); } main( ) { int i; int x ,n; char name[4]; int size,tcount,pcount,wtime,rtime; JCB *p; memory=65536; tape=4; printer=2; head=NULL; printf("\n please inputs the quantity of JCB...\n"); scanf("%d",&n); printf("---------------------------------------------------------------\n"); for(i=0;iname,name); p->length=size; p->printer=pcount; p->tape=tcount; p->runtime=rtime; p->waittime=wtime; p->next=head; head=p;} printf("---------------------------------------------------------------\n" "[1]_The response compares first the algorithm\n" "[2]_Short work first algorithm\n" "---------------------------------------------------------------\n" "please chose [1]or[2]...\n"); scanf("%d",&x); switch (x){ case 1:shedule(); printf("---------------------------------------------------------------\n"); break; case 2:inital(); printf("---------------------------------------------------------------\n"); break; default:printf("\n error..please try again!\n");main(); } } ...展开收缩
(系统自动生成,下载前可以参看下载内容)
下载文件列表
相关说明
- 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
- 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度。
- 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
- 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
- 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
- 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.