test.java

来自「页面置换算法 包括fifo 先进现出」· Java 代码 · 共 38 行

JAVA
38
字号
package 操作系统;

import java.util.Arrays;

public class test {// 最近最少使用置换算法(LRU)
	public static final int PROGRAMNUM = 24;
	public static final int SIGMA = 5;
	public static final int MIU = 6;

	public static void main(String[] args) {
		int[] a = new int[25];
		for (int i = 0; i < 25; i++)
			a[i] = Norm_rand();
		Arrays.sort(a);
		for (int m : a)
			System.out.print(" " + m);
	}

	public static int Norm_rand() {
		double N = 12;
		double x = 0, temp = N;
		do {
			x = 0;
			for (int i = 0; i < N; i++)
				x = x + (Math.random());
			x = (x - temp / 2) / (Math.sqrt(temp / 12));
			x = MIU + x * Math.sqrt(SIGMA);
		} while (x <= 0); // 在此我把小于0的数排除掉了
		int m = (int) x;
		if (m <= 0)
			m = 1;
		else if (m > PROGRAMNUM)
			m = PROGRAMNUM;
		return m;

	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?