📄 test.java
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -