#include#include#includetypedefstructProcessNode{//进程结点的基本结构charname;//进程名intservice_time;//服务时间intarrive_time;//到达时间intpriority;//优先级structFCFS_time{//先到先服务intfinish_time;//完成时间intturnaround_time;//周转时间floatweigtharound_time;//带权周转时间}FCFS_time;structSJF_time{//短作业优先intfinish_time;intturnaround_time;floatweigtharound_time;intflag;}SJF_time;structRR_time{//时间片轮转的结点intfinish_time;intturnaround_time;floatweigtharound_time;intflag_time;//赋值为进程的服务时间,为0则进程完成}RR_time;structPri_time{//优先权非抢占式intfinish_time;intturnaround_time;floatweigtharound_time;}Pri_time;structProcessNode*next;}ProcessNode,*Linklist;voidmain(){intchoice;Linklistp,head;Linklistread_information();LinklistFCFS_scheduling(Linklisthead);LinklistSJF_scheduling(Linklisthead);LinklistRR_scheduling(Linklisthead);LinklistPri_scheduling(Linklisthead);head=read_information();//读入进程的基本信息do{p=head->next;printf("\n");printf("**********进程初始信息输出**********\n");//输出初始化后的进程基本信息printf("\n");printf("进程名称");printf("到达时间");printf("服务时间");printf("优先级");printf("\n");while(p){printf("%c",p->name);printf("%d",p->arrive_time);printf("%d",p->service_time);printf("%d",p->priority);printf("\n");p=p->next;}printf("\n");printf("************************************\n");//输出进程的调用选择项printf("\n");printf("1、FCFS----先到先服务\n");printf("2、SJF-----短作业优先\n");printf("3、RR------时间片轮转\n");printf("4、Pri-----优先权调度\n");printf("5、退出\n");printf("\n");printf("************************************\n");printf("\n");printf("请在1—5之间选择:");scanf("%d",&choice);printf("\n");printf("\n");switch(choice){case1:FCFS_scheduling(head);break;case2:SJF_scheduling(head);break;case3:RR_scheduling(head);break;case4:Pri_scheduling(head);break;//case5:exit();}}while(choice!=5);}Linklistread_information()//进程读入函数{inti;intnum;//ProcessNode;Linklistpro;Linklistp;Linklisthead;printf("\n");printf("************进程调度算法************\n");printf("\n");printf("请输入进程的个数:");scanf("%d",&num);printf("\n");printf("*************初始化信息*************\n");printf("\n");head=(Linklist)malloc(sizeof(ProcessNode));//头结点head->next=NULL;p=head;for(i=1;i<=num;i++){pro=(Linklist)malloc(sizeof(ProcessNode));//创建进程结点printf("输入第%d个进程信息:\n",i);printf("请输入进程名:");fflush(stdin);scanf("%c",&pro->name);printf("到达时间:");scanf("%d",&pro->arrive_time);printf("服务时间:");scanf("%d",&pro->service_time);printf("优先级↑:");scanf("%d",&pro->priority);//pro->next=head->next;head->next=pro;//逆序建链p->next=pro;p=pro;//顺序建链//p++;pro->next=NULL;}printf("\n");returnhead;}LinklistFCFS_scheduling(Linklisthead)//先到先服务算法函数{Linklistp;Linklistq;//指向前一进程p=head->next;while(p)//初始化进程的完成时间、周转时间、带权周转时间,初值均赋为0{p->FCFS_time.finish_time=0;p->FCFS_time.turnaround_time=0;p->FCFS_time.weigtharound_time=0;p=p->next;}p=q=head->next;p->FCFS_time.finish_time=p->arrive_time;//避免第一个进程到达时间不为0while(p){if(p->arrive_time<=q->FCFS_time.finish_time)//下一进程已到达,在等待中{p->FCFS_time.finish_time=(p->service_time)+(q->FCFS_time.finish_time);//服务时间p->FCFS_time.turnaround_time=(p->FCFS_time.finish_time)-(p->arrive_time);//周转时间p->FCFS_time.weigtharound...