計算機(jī)操作系統(tǒng)課程設(shè)計源代碼《通用處理機(jī)調(diào)度演示程序源代碼》_第1頁
計算機(jī)操作系統(tǒng)課程設(shè)計源代碼《通用處理機(jī)調(diào)度演示程序源代碼》_第2頁
計算機(jī)操作系統(tǒng)課程設(shè)計源代碼《通用處理機(jī)調(diào)度演示程序源代碼》_第3頁
計算機(jī)操作系統(tǒng)課程設(shè)計源代碼《通用處理機(jī)調(diào)度演示程序源代碼》_第4頁
計算機(jī)操作系統(tǒng)課程設(shè)計源代碼《通用處理機(jī)調(diào)度演示程序源代碼》_第5頁
已閱讀5頁,還剩24頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)

文檔簡介

通用處理機(jī)調(diào)度演示程序源代碼》//短作業(yè)優(yōu)先算法#defineMaxNum100#include<stdio.h>#include<stdlib.h>#include<string.h>//進(jìn)程編號//進(jìn)程名稱//進(jìn)程編號//進(jìn)程名稱charName[MaxNum];intArrivalTime;intServiceTime;intFinishTime;intWholeTime;intrun_flag;intorder;//到達(dá)時間//開始運(yùn)行時間//運(yùn)行結(jié)束時間//運(yùn)行時間//調(diào)度標(biāo)志//運(yùn)行次序doubleWeightWholeTime;//周轉(zhuǎn)時間doubleAverageWT_FCFS,AverageWT_SJF;//平均周轉(zhuǎn)時間doubleAverageWWT_FCFS,AverageWWT_SJF;//平均帶權(quán)周轉(zhuǎn)時間}Process[MaxNum];intN;//實(shí)際進(jìn)程個數(shù)intSJF();//短作業(yè)優(yōu)先intSJF(){//短作業(yè)優(yōu)先算法inttemp_time=0;//當(dāng)期那時間inti=0,j;intnumber_schedul,temp_counter;//進(jìn)程編號,當(dāng)前已執(zhí)行進(jìn)程個數(shù)floatrun_time;run_time=Process[i].WholeTime;j=1;while((j<N)&&(Process[i].ArrivalTime==Process[j].ArrivalTime))//判斷是否有兩個進(jìn)程同時到達(dá){if(Process[j].WholeTime<Process[i].WholeTime)run_time=Process[i].WholeTime;i=j;}j++;}//查找下一個被調(diào)度的進(jìn)程//對找到的下一個被調(diào)度的進(jìn)程求相應(yīng)的參數(shù)number_schedul=i;Process[number_schedul].ServiceTime=Process[number_schedul].ArrivalTime;Process[number_schedul].FinishTime=Process[number_schedul].ServiceTime+Process[number_schedul].WholeTime;Process[number_schedul].run_flag=1;temp_time=Process[number_schedul].FinishTime;Process[number_schedul].order=1;temp_counter=1;while(temp_counter<N){for(j=0;j<N;j++){if((Process[j].ArrivalTime<=temp_time)&&(!Process[j].run_flag)){run_time=Process[j].WholeTime;number_schedul=j;break;}}for(j=0;j<N;j++){if((Process[j].ArrivalTime<=temp_time)&&(!Process[j].run_flag))if(Process[j].WholeTime<run_time){run_time=Process[j].WholeTime;number_schedul=j;}//查找下一個被調(diào)度的進(jìn)程//對找到的下一個被調(diào)度的進(jìn)程求相應(yīng)的參數(shù)Process[number_schedul].ServiceTime=temp_time;Process[number_schedul].FinishTime=Process[number_schedul].ServiceTime+Process[number_schedul].WholeTime;Process[number_schedul].run_flag=1;temp_time=Process[number_schedul].FinishTime;temp_counter++;Process[number_schedul].order=temp_counter;}return0;}intPinput();//進(jìn)程參數(shù)輸入intPoutput();//調(diào)度結(jié)果輸出intPinput()//進(jìn)程參數(shù)輸入{inti;printf("請輸入進(jìn)程個數(shù):\n");scanf("%d",&N);for(i=0;i<N;i++){printf(" \n");printf("請輸入一個進(jìn)程:\n",i+1);printf("請輸入進(jìn)程名稱:\n");scanf("%s",Process[i].Name);printf("請輸入到達(dá)時間:\n");scanf("%d",&Process[i].ArrivalTime);printf("請輸入服務(wù)時間:\n");scanf("%d",&Process[i].WholeTime);Process[i].ServiceTime=0;Process[i].FinishTime=0;Process[i].WeightWholeTime=0;Process[i].order=0;Process[i].run_flag=0;}return0;}intPoutput()//調(diào)度結(jié)果輸出{inti;floatturn_round_time=0,f1,w=0;printf("進(jìn)程名稱到達(dá)時間運(yùn)行時間開始運(yùn)行時間結(jié)束時間執(zhí)行順序周轉(zhuǎn)時間帶權(quán)周轉(zhuǎn)時間\n");for(i=0;i<N;i++){Process[i].WeightWholeTime=Process[i].FinishTime-Process[i].ArrivalTime;f1=Process[i].WeightWholeTime/Process[i].WholeTime;turn_round_time+=Process[i].WeightWholeTime;w+=f1;printf("時亥刻%d:",Process[i].ServiceTime,Process[i].Name);printf("%s%d%d %d %d %d%f%f\n",Process[i].Name,Process[i].ArrivalTime,Process[i].WholeTime,Process[i].ServiceTime,Process[i].FinishTime,Process[i].order,Process[i].WeightWholeTime,f1);}printf("average_turn_round_timer=%f\n",turn_round_time/N);printf("weight_average_turn_round_timer=%f\n",w/N);return0;//時間片輪轉(zhuǎn)算法typedefstructnode{charname[20];intround;intcputime;intarrivetime;intneedtime;charstate;intcount;structnode*next;}PCB;PCB*ready=NULL,*run1=NULL,*finish=NULL;intnum,i;voidGetFirst();voidOutput();voidInsertTime(PCB*in);voidInsertFinish(PCB*in);voidTimeCreate();voidRoundRun();voidGetFirst()/*取得第一個就緒隊列節(jié)點(diǎn)*/{run1=ready;if(ready!=NULL){run1->state='R';ready=ready->next;run1->next=NULL;}voidOutput()/*輸出隊列信息*/{PCB*p;p=ready;printf("進(jìn)程名\tcpu時間\t需要時間\t進(jìn)程狀態(tài)\t計數(shù)器\n");while(p!=NULL){printf("%s\t%d\t%d\t\t%c\t\t%d\n",p->name,p->cputime,p->needtime,p->state,p->count);p=p->next;}p=finish;while(p!=NULL){printf("%s\t%d\t%d\t\t%c\t\t%d\n",p->name,p->cputime,p->needtime,p->state,p->count);p=p->next;}p=run1;while(p!=NULL){printf("%s\t%d\t%d\t\t%c\t\t%d\n",p->name,p->cputime,p->needtime,p->state,p->count);p=p->next;}}voidInsertTime(PCB*in)/*將進(jìn)程插入到就緒隊列尾部*/{PCB*fst;fst=ready;if(ready==NULL){in->next=ready;ready=in;}else{while(fst->next!=NULL){fst=fst->next;}in->next=fst->next;fst->next=in;}}voidInsertFinish(PCB*in)/*將進(jìn)程插入到完成隊列尾部*/{PCB*fst;fst=finish;if(finish==NULL){in->next=finish;finish=in;}else{while(fst->next!=NULL){fst=fst->next;}in->next=fst->next;fst->next=in;}}voidTimeCreate()/*時間片輸入函數(shù)*/{PCB*tmp;inti;printf("輸入進(jìn)程名字到達(dá)時間進(jìn)程所需時間時間片大?。篭n");for(i=0;i<num;i++){if((tmp=(PCB*)malloc(sizeof(PCB)))==NULL){perror("malloc");exit(1);}scanf("%s%d%d%d",tmp->name,&(tmp->arrivetime),&(tmp->needtime),&(tmp->round));getchar();tmp->cputime=0;tmp->state='W';//tmp->prio=0;tmp->count=0;InsertTime(tmp);}}voidRoundRun()/*時間片輪轉(zhuǎn)調(diào)度算法*/{intflag=1;GetFirst();while(run1!=NULL){Output();while(flag){run1->cputime++;run1->needtime--;run1->count++;if(run1->needtime==0){run1->state='F';InsertFinish(run1);flag=0;}elseif(run1->count==run1->round){run1->state='W';run1->count=0;InsertTime(run1);flag=0;}}flag=1;GetFirst();}}//先來先服務(wù)算法typedefstructPCB//定義進(jìn)程控制塊{charID[3];//進(jìn)程號charname[10];//進(jìn)程名charstate;//運(yùn)行狀態(tài)intarrivetime;//到達(dá)時間intstarttime;//進(jìn)程開始時間intfinishtime;//進(jìn)程結(jié)束時間intservicetime;//服務(wù)時間floatturnaroundtime;//周轉(zhuǎn)時間floatweightedturnaroundtime;//帶權(quán)周轉(zhuǎn)時間structPCB*next;//指向下個進(jìn)程}pcb;inttime;//計時器intn;//進(jìn)程個數(shù)pcb*head1=NULL,*p,*q;//進(jìn)程鏈表指針voidrun_fcfs(pcb*p1)//運(yùn)行未完成的進(jìn)程{time=p1->arrivetime>time?p1->arrivetime:time;p1->starttime=time;printf("\n現(xiàn)在時間是%d,開始運(yùn)行作^%s\n",time,p1->name);time+=p1->servicetime;p1->state='T';p1->finishtime=time;p1->turnaroundtime=p1->finishtime-p1->arrivetime;p1->weightedturnaroundtime=p1->turnaroundtime/p1->servicetime;printf("ID到達(dá)時間開始時間服務(wù)時間完成時間周轉(zhuǎn)時間帶權(quán)周轉(zhuǎn)時間\n");printf("%s%6d%10d%10d%8d%10.1f%10.2f\n",p1->ID,p1->arrivetime,p1->starttime,p1->servicetime,p1->finishtime,p1->turnaroundtime,p1->weightedturnaroundtime);}voidfcfs()//找到當(dāng)前未完成的進(jìn)程{inti,j;p=head1;for(i=0;i<n;i++){if(p->state=='F'){q=p;//標(biāo)記當(dāng)前未完成的進(jìn)程run_fcfs(q);}p=p->next;}}voidgetInfo()//獲得進(jìn)程信息并創(chuàng)建進(jìn)程{intnum;printf("\n作業(yè)個數(shù):");scanf("%d",&n);for(num=0;num<n;num++){p=(pcb*)malloc(sizeof(pcb));printf("依次輸入:\nID進(jìn)程名到達(dá)時間服務(wù)時間\n");scanf("%s\t%s\t%d\t%d",&p->ID,&p->name,&p->arrivetime,&p->servicetime);if(head1==NULL){head1=p;q=p;time=p->arrivetime;}if(p->arrivetime<time)time=p->arrivetime;q->next=p;p->starttime=0;p->finishtime=0;p->turnaroundtime=0;p->weightedturnaroundtime=0;p->next=NULL;p->state='F';

q=p;//靜態(tài)優(yōu)先權(quán)優(yōu)先算法intSequenceNumber=1;//進(jìn)程編號intProcessAmount;//進(jìn)程數(shù)量intProcessAmount;intStartCount=0;//調(diào)入內(nèi)存進(jìn)程計數(shù)structPCB1{//進(jìn)程控制塊intNo;intNo;//進(jìn)程號charname[16];//進(jìn)程名intenterMemoryTime;//進(jìn)入內(nèi)存時間intserviceTime;//服務(wù)時間intpriority;//優(yōu)先級structPCB1*next;};//動態(tài)接收進(jìn)程及詳細(xì)structPCB1*head,*thisP,*newP;//動態(tài)接收進(jìn)程及詳細(xì)structPCB1*readyHead;//動態(tài)存儲就緒隊列//函數(shù)聲明intgetch();inttimeOfData(FILE*);voidListAllPCB();voidMenu();voidprintPCB(structPCB1*,int,int,int,double);voidprintPCBP(structPCB1*);voidprintField();voidprintFieldP();voidrelease(structPCB1*);voidreleaseR(structPCB1*);voidsetNewPCB(char*,int,int,int);structPCB1*runTheProcess();voidnewPCB(){ //建立PCBnewP=(structPCB1*)malloc(sizeof(structPCB1));if(head==NULL){ //判斷頭節(jié)點(diǎn)是否為空head=newP; //為空,頭節(jié)點(diǎn)指向新開辟的內(nèi)存}else{thisP=head;while(thisP->next!=NULL){thisP=thisP->next;}thisP->next=newP;//遍歷單鏈表,找到最后一個元素}thisP=newP;thisP->No=SequenceNumber;SequenceNumber++;printf("進(jìn)程號%d\n",thisP->No);printf("輸入進(jìn)程名:");scanf("%s",thisP->name);printf("輸入優(yōu)先級:");scanf("%d",&thisP->priority);printf("輸入進(jìn)入內(nèi)存時間:");scanf("%d",&thisP->enterMemoryTime);printf("輸入服務(wù)時間:");scanf("%d",&thisP->serviceTime);thisP->next=NULL;voidbuildProcess(){//創(chuàng)建進(jìn)程inti=0;printf("輸入進(jìn)程數(shù)量:");scanf("%d",&ProcessAmount);while(i<ProcessAmount){newPCB();i++;}}voidreadyList(structPCB1*pcb){ //單鏈表的形式創(chuàng)建就緒隊列newP=(structPCB1*)malloc(sizeof(structPCB1));if(readyHead==NULL){readyHead=newP;}else{thisP=readyHead;while(thisP->next!=NULL){thisP=thisP->next;}thisP->next=newP;}thisP=newP;strcpy(thisP->name,pcb->name);thisP->No=pcb->No;thisP->priority=pcb->priority;thisP->enterMemoryTime=pcb->enterMemoryTime;thisP->serviceTime=pcb->serviceTime;thisP->next=NULL;}structPCB1*callMemory(){//調(diào)入內(nèi)存,返回調(diào)入內(nèi)存的鏈表節(jié)點(diǎn)intat; //到達(dá)時間structPCB1*markP;if(head==NULL){printf("程序沒有找到。\n");}else{markP=thisP=head;//標(biāo)記指向頭節(jié)點(diǎn)at=thisP->enterMemoryTime;//到達(dá)時間為頭節(jié)點(diǎn)到達(dá)時間while(thisP->next!=NULL){//當(dāng)下一節(jié)點(diǎn)不為空if(at>thisP->next->enterMemoryTime){//判斷當(dāng)前時間是否大于下一節(jié)點(diǎn)時間markP=thisP->next; //是,標(biāo)記此節(jié)點(diǎn)at=markP->enterMemoryTime;//到達(dá)時間更改為標(biāo)記時間}thisP=thisP->next;//向后遍歷}}returnmarkP;}voidrun(){//靜態(tài)優(yōu)先級算法執(zhí)行。structPCB1*temp;//臨時節(jié)點(diǎn)用來存儲調(diào)入內(nèi)存節(jié)點(diǎn)structPCB1*runPro;//用來接收執(zhí)行的節(jié)點(diǎn)inti; //循環(huán)初始條件intat,srt,runtime=0; //到達(dá)時間,開始執(zhí)行時間,運(yùn)行時間。intturnOverTime; //周轉(zhuǎn)時間doubleptot; //帶權(quán)周轉(zhuǎn)時間if(head==NULL){printf("沒有發(fā)現(xiàn)進(jìn)程。\n");}else{for(i=0;i<ProcessAmount;i++){//循環(huán)進(jìn)程的數(shù)量次while(head!=NULL){temp=callMemory();if(i==O){//初始情況下球開始執(zhí)行時間,完成時間,周轉(zhuǎn)時間,帶權(quán)周轉(zhuǎn)時間srt=at=temp->enterMemoryTime;runtime=at+temp->serviceTime;turnOverTime=runtime-at;ptot=turnOverTime*1.0/temp->serviceTime;}readyList(temp);//初始納入就緒列表以及后續(xù)release(temp); //釋放進(jìn)程while(head!=NULL&&(temp=callMemory())->enterMemoryTime<=runtime){readyList(temp);//循環(huán)判斷是否納入就緒列表release(temp);}}runPro=runTheProcess();if(i>0){//初始之后,計算各時間及周轉(zhuǎn)srt=runtime;runtime+=runPro->serviceTime;turnOverTime=runtime-runPro->enterMemoryTime;ptot=turnOverTime*1.0/runPro->serviceTime;}printf("當(dāng)前執(zhí)行的進(jìn)程:\n");printField();printPCB(runPro,srt,runtime,turnOverTime,ptot);releaseR(runPro);printf("\n就緒進(jìn)程列表:\n");ListAllPCB(readyHead);printf("\n");}}}structPCB1*runTheProcess(){//執(zhí)行的進(jìn)程,返回要執(zhí)行進(jìn)程的節(jié)點(diǎn)inttime,pri;structPCB1*markThis;//標(biāo)記要返回的節(jié)點(diǎn)if(readyHead==NULL){printf("沒有可運(yùn)行的進(jìn)程。\n");}else{markThis=thisP=readyHead;time=thisP->enterMemoryTime;//當(dāng)前到達(dá)時間pri=thisP->priority;//當(dāng)前進(jìn)程的優(yōu)先級while(thisP->next!=NULL){遷(time==thisP->next->enterMemoryTime){//判斷之后節(jié)點(diǎn)的到達(dá)時間是否與當(dāng)前一致if(pri<thisP->next->priority){//—致,則判斷優(yōu)先級決定pri=thisP->next->priority;//更改優(yōu)先級判斷條件為下一優(yōu)先級markThis=thisP->next;//標(biāo)記當(dāng)前節(jié)點(diǎn)的下一節(jié)點(diǎn)}}else{break;}thisP=thisP->next;}}returnmarkThis;}voidrelease(structPCB1*pcb){//刪除原單鏈表的進(jìn)程節(jié)點(diǎn)structPCB1*markP,*f;markP=head;if(pcb!=NULL){if(pcb==head){f=head;head=head->next;free(f);}else{thisP=head->next;while(thisP!=NULL){if(pcb==thisP){f=thisP;markP->next=thisP->next;free(f);break;}else{markP=thisP;}thisP=thisP->next;}}}}voidreleaseR(structPCB1*pcb){//刪除就緒列表中進(jìn)程節(jié)點(diǎn)structPCB1*markP,*f;markP=readyHead;if(pcb!=NULL){if(pcb==readyHead){f=readyHead;readyHead=readyHead->next;free(f);}else{thisP=readyHead->next;while(thisP!=NULL){if(pcb==thisP){f=thisP;markP->next=thisP->next;free(f);break;}else{markP=thisP;}thisP=thisP->next;}voidListAllPCB(structPCB1*h){//打印所有進(jìn)程printFieldP();if(h==NULL){printf("沒有進(jìn)程。\n");}else{thisP=h;while(thisP!=NULL){printPCBP(thisP);thisP=thisP->next;}}printf("\n按任意鍵繼續(xù)...\n");printf("\n\n");}voidprintPCB(structPCB1*pcb,inta,intb,intc,doubled){//打印單個數(shù)據(jù)結(jié)果if(pcb!=NULL){printf("%-8s%-8d%-8d%-8d%-8d",pcb->name,pcb->No,pcb->priority,pcb->enterMemoryTime,pcb->serviceTime);printf("%-8d%-8d%-8d%-8.2lf\n",a,b,c,d);}elseprintf("沒有進(jìn)程。\n");}voidprintPCBP(structPCB1*pcb){if(pcb!=NULL)printf("%-8s%-8d%-8d%-8d%-8d\n",pcb->name,pcb->No,pcb->priority,pcb->enterMemoryTime,pcb->serviceTime);else

printf("投有進(jìn)程。\n");voidprintField(){//打印表頭,以及周轉(zhuǎn)時間printf("\n");printf("進(jìn)程名\t進(jìn)程號\t優(yōu)先級\t到達(dá)時\t服務(wù)時\t開始執(zhí)\t完成時\t周轉(zhuǎn)時\t帶權(quán)周\n");printf("\t\t\t間\t間\t行時間\t間\t間\t轉(zhuǎn)時間\n");}voidprintFieldP(){ //打印表頭,字段printf("\n");printf(-進(jìn)程名\t進(jìn)程號\t優(yōu)先級\t到達(dá)時\t服務(wù)時\n");printf("\t\t\t間\t間\n");}//從文件讀取數(shù)據(jù)/*數(shù)據(jù)格式如下進(jìn)程名優(yōu)先級到達(dá)時間服務(wù)時間進(jìn)程名優(yōu)先級到達(dá)時間服務(wù)時間10112TOC\o"1-5"\h\zproc1 2 110112proc2 2 1proc3 3 2*/voidreadFromFile(){FILE*fp;inttimes;inti=0;charfilePath[20],temp[8];charname[16];intpri,emt,st;printf("輸入文件路徑:");scanf("%s",filePath);fp=fopen(filePath,"r");times=timeOfData(fp);ProcessAmount=times-2;while(i<times-1){if(i==0){//這是用來接收文本格式第一行的漢字。fscanf(fp,"%s",temp);fscanf(fp,"%s",temp);fscanf(fp,"%s",temp);fscanf(fp,"%s",temp);}else{//以下用來接收進(jìn)程數(shù)據(jù)fscanf(fp,"%s",name);fscanf(fp,"%d",&pri);fscanf(fp,"%d",&emt);fscanf(fp,"%d",&st);setNewPCB(name,pri,emt,st);}i++;}fclose(fp);}voidsetNewPCB(char*name,intpri,intentime,intsertime){//賦值建立PCB,用于從文本中獲取數(shù)據(jù)newP=(structPCB1*)malloc(sizeof(structPCB1));if(head==NULL){head=newP;}else{thisP=head;while(thisP->next!=NULL){thisP=thisP->next;thisP->next=newP;}thisP=newP;thisP->No=SequenceNumber;SequenceNumber++;strcpy(thisP->name,name);thisP->priority=pri;thisP->enterMemoryTime=entime;thisP->serviceTime=sertime;thisP->next=NULL;}inttimeOfData(FILE*f){//求取從文本中獲取數(shù)據(jù)的進(jìn)程數(shù)量chartemp[20];inti=0;if(f==NULL){printf("文件沒有找到。\n");exit(0);}else{while(fgets(temp,20,f)!=NULL){i++;}}rewind(f);returni;}voidMenu(){//菜單intflag=1;intse;while(flag){printf(" 12軟工3班陳宇鋒談澤宇printf(" \n");printf("--靜態(tài)優(yōu)先權(quán)優(yōu)先算法進(jìn)程調(diào)度--\n");printf(" \n");printf("1.進(jìn)程調(diào)度模擬\n");printf("O.退出\n");printf("請選擇:");scanf("%d",&se);fflush(stdin); //清空緩沖區(qū),用于解決輸入字符串發(fā)生死循環(huán)的問題switch(se){case1:{buildProcess();printf("進(jìn)程列表:");ListAllPCB(head);run();}break;caseO:flag=O;break;default:printf("請輸入正確選項。\n\n");break;}SequenceNumber=1;StartCount=O;}}//高響應(yīng)比調(diào)度算法intN;structzgxyb*c;structzgxyb{charname[10];floatarrivetime;floatservicetime;floatstarttime;floatfinishtime;floatzztime;floatdqzztime;};structzgxyba[100];voidinput(structzgxyb*p,intN){inti;printf("請分別輸入進(jìn)程名到達(dá)時間要求服務(wù)時間:\n例如:a0100\n");for(i=0;i<=N-1;i++){printf("請輸入第%4個的進(jìn)程信息:\n",i+1);scanf("%s%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<N;k++){printf("-->%s",p[k].name);}printf("\n當(dāng)前執(zhí)行進(jìn)程信息:\n");printf("\n進(jìn)程名到達(dá)時間服務(wù)時間開始執(zhí)行時間完成時間周轉(zhuǎn)時間帶權(quán)周轉(zhuǎn)時間\n");for(k=0;k<=N-1;k++){printf("%s\t%-.2f\t%-.2f\t%-.2f\t%-.2f\t%-.2f\t%-.2f\t\n",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<p[j].arrivetime){structzgxybtemp;temp=p[i];p[i]=p[j];p[j]=temp;}}//yunxingjieduanvoiddeal(structzgxyb*p,floatarrivetime,floatservicetime,floatstarttime,floatfinishtime,floatzztime,floatdqzztime,intN){intk;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{p[k].starttime=p[k-1].finishtime;p[k].finishtime=p[k-1].finishtime+p[k].servicetime;}}for(k=0;k<=N-1;k++){p[k].zztime=p[k].finishtime-p[k].arrivetime;p[k].dqzztime=p[k].zztime/p[k].servicetime;}}voidZGXYB(structzgxyb*p,intN){floatarrivetime=0,servicetime=0,starttime=0,fin

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論