操作系统实验一:编写程序,实现SJF作业调度算法,模拟作业调度过程,加深对作业调度的理解。
代码如下(示例):
tips:假定没有作业同时到达
#include<bits/stdc++.h>
#define endl '\n'
#define IOS ios::sync_with_stdio(0)
typedef long long ll;
const int N = 1e3+7;
using namespace std;
typedef struct{
char name[15]; //作业名称
float serT; //服务时间
float arrT; //到达时间
float staT; //开始时间
float finT; //结束时间
float zzT; //周转时间
float dqzzT; //带权周转时间
} JCB;
bool cmp1(JCB a, JCB b){
return a.arrT < b.arrT; } //按到达时间比较
bool cmp2(JCB a, JCB b){
return a.serT < b.serT; } //按服务时间比较
void SJF(JCB *j, int n){
sort(j + 1, j + n +