FCFS——First Come First Serve,顾名思义,就是先来先服务算法,下面有在github上找的代码,改了一些东西,如下:
package org.cloudbus.cloudsim.examples;
import java.util.*;
public class Lab1 {
public static int[] CreateRandom() {
int min =2;
int max =10;
max-=min;
int m = (int) (Math.random()*++max)+min;
int[] mas = new int[m];
System.out.println("The number of " + m + " processes was created");
for (int i = 0; i < mas.length; i++) {
double k = Math.random();
int l = (int) (k * 100);
System.out.println("The burst time of the process [" + i + "] is " + l);
mas[i] = l;
}
return mas;
}
public static int[] procn(int mas[])
{
int n = mas.length;
int[] k = new int[n];
for(int i=1;i<=n;i++)
{
k[i-1]=i;
}
return k;
}
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
outer1:
while (true) {
System.out.println("Pls, enter the number of the operation you want to do");
System.out.println("1. Create a new set of processes");
System.out.println("2. Conc